當前位置: 首頁>>代碼示例>>Java>>正文


Java StringBufferInputStream類代碼示例

本文整理匯總了Java中java.io.StringBufferInputStream的典型用法代碼示例。如果您正苦於以下問題:Java StringBufferInputStream類的具體用法?Java StringBufferInputStream怎麽用?Java StringBufferInputStream使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StringBufferInputStream類屬於java.io包,在下文中一共展示了StringBufferInputStream類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import java.io.StringBufferInputStream; //導入依賴的package包/類
public static void main(String[] args) throws IOException {
		byte[] srcBuf = new byte[SRC.length()];
		InputStream input = new IncludeToLowerInputStream( new StringBufferInputStream(SRC) );
//		InputStream input =  new StringBufferInputStream(SRC) ;

		if ( TGT.length() != input.read(srcBuf)) {
			System.err.println("too few charcaters in converted string");
			System.exit(0);
		};

		if (! TGT.equals(new String(srcBuf))) {
			System.err.println("Converted string not equal to expected string");
			System.exit(0);
		}
		
		System.out.println("Everything went accroding to plans");

		input.close();  // useless but avoid warnings in Eclipse
	}
 
開發者ID:Synectique,項目名稱:VerveineC-Cpp,代碼行數:20,代碼來源:IncludeFilterTest.java

示例2: runTest

import java.io.StringBufferInputStream; //導入依賴的package包/類
void runTest(String xmlString) {
    Bug6573786ErrorHandler handler = new Bug6573786ErrorHandler();
    try {
        InputStream is = new StringBufferInputStream(xmlString);
        SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
        parser.parse(is, handler);
    } catch (Exception e) {
        if (handler.fail) {
            Assert.fail("The value of standalone attribute should be merged into the error message.");
        }
    }

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:Bug6573786.java

示例3: getDemoList

import java.io.StringBufferInputStream; //導入依賴的package包/類
private static VectorD getDemoList(String sourceFileName) {
	BufferedReader r;
    if (Debugger.clazz == com.lambda.Debugger.QuickSortNonThreaded.class) {
	r = new BufferedReader(new InputStreamReader(new StringBufferInputStream(QuickSortNonThreadedString.programString)));
	return(buildFileLines(r, sourceFileName));
    }
    if (Debugger.clazz == com.lambda.Debugger.Rewrite.class) {
	r = new BufferedReader(new InputStreamReader(new StringBufferInputStream(RewriteString.programString)));
	return(buildFileLines(r, sourceFileName));
    }
    if (Debugger.clazz == com.lambda.Debugger.Demo.class) {
	r = new BufferedReader(new InputStreamReader(new StringBufferInputStream(DemoString.programString)));
	return(buildFileLines(r, sourceFileName));
    }
return null;
}
 
開發者ID:OmniscientDebugger,項目名稱:LewisOmniscientDebugger,代碼行數:17,代碼來源:CodePane.java

示例4: compareWithAntrl

import java.io.StringBufferInputStream; //導入依賴的package包/類
@Test
public void compareWithAntrl() {
	String s = "select " + "*" + "from dbo.test";
	AntrlResult result = Antlr4Utils.getFull(s);
	SourceLinesProvider p = new SourceLinesProvider();
	SourceLine[] lines = p.getLines(new StringBufferInputStream(s), Charset.defaultCharset());
	FillerRequest file = new FillerRequest(null, null, result.getTree(), lines);
	for (Token t : result.getStream().getTokens()) {
		if (t.getType() == Token.EOF) {
			continue;
		}
		int[] start = file.getLineAndColumn(t.getStartIndex());
		int[] end = file.getLineAndColumn(t.getStopIndex());
		Assert.assertNotNull(start);
		Assert.assertNotNull(end);
		Assert.assertEquals(t.getLine(), start[0]);
		System.out.println(t.getText() + Arrays.toString(start) + " " + t.getCharPositionInLine() + " "
				+ t.getLine() + " " + Arrays.toString(end));
		Assert.assertEquals(t.getCharPositionInLine(), start[1]);
	}
}
 
開發者ID:gretard,項目名稱:sonar-tsql-plugin,代碼行數:22,代碼來源:AntrlFileTest.java

示例5: main

import java.io.StringBufferInputStream; //導入依賴的package包/類
/**
 * Used for testing and demonstration purposes.
 */
static public void main(String args[]) throws Exception, java.io.IOException {
    try {
        //String xx = "------=_Part_2_9110923.1073664290010\r\nContent-Type: text/plain\r\nContent-ID: urn:uuid:d4bfb124-7922-45bc-a03d-823351eed716\r\n\r\nhttp://ratbert.ncsl.nist.gov:8081/hl7services/transform.html\r\n------=_Part_2_9110923.1073664290010\r\nContent-Type: text/plain\r\nContent-ID: urn:uuid:45b90888-49c1-4b64-a8eb-e94f541368f0\r\n\r\nhttp://ratbert.ncsl.nist.gov:8081/hl7services/rawSQL.html\r\n------=_Part_2_9110923.1073664290010--\r\n";
        String xx = "------_Part_\r\nContent-Type: text/plain\r\nContent-ID: urn:uuid:d4bfb124-7922-45bc-a03d-823351eed716\r\n\r\nhttp://ratbert.ncsl.nist.gov:8081/hl7services/transform.html\r\n------_Part_\r\nContent-Type: text/plain\r\nContent-ID: urn:uuid:45b90888-49c1-4b64-a8eb-e94f541368f0\r\n\r\nhttp://ratbert.ncsl.nist.gov:8081/hl7services/rawSQL.html\r\n------_Part_--\r\n";
        StringBufferInputStream is = new StringBufferInputStream(xx);
        String contentType = "multipart/related; boundary=----_Part_";
        ByteArrayDataSource ds = new ByteArrayDataSource(is,  contentType);
        //ByteArrayDataSource ds = new ByteArrayDataSource();
        javax.mail.internet.MimeMultipart mp = new javax.mail.internet.MimeMultipart(ds);
        int i = mp.getCount();
    } catch (javax.mail.MessagingException me) {
        throw new Exception("messaging exception in parsing for MultipartMap");
    }
    System.out.println("Done");
}
 
開發者ID:jembi,項目名稱:openxds,代碼行數:19,代碼來源:MultipartMap.java

示例6: testTransitiveDep

import java.io.StringBufferInputStream; //導入依賴的package包/類
public void testTransitiveDep(){
    cu.addSource("testTransitiveDep.gtest", new StringBufferInputStream(
            "class A1 {}\n" +
            "class A2 extends A1{}\n" +
            "class A3 extends A2{}\n"
    ));
    cu.compile(Phases.CLASS_GENERATION);
    cache.makeTransitiveHull();
     
    Set<String> dep = cache.get("A1");
    assertEquals(dep.size(),1);
    
    dep = cache.get("A2");
    assertEquals(dep.size(),2);
    assertTrue(dep.contains("A1"));
    
    dep = cache.get("A3");
    assertEquals(dep.size(),3);
    assertTrue(dep.contains("A1"));
    assertTrue(dep.contains("A2"));
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:22,代碼來源:DependencyTest.java

示例7: sysinFileout

import java.io.StringBufferInputStream; //導入依賴的package包/類
/**
 * <p>
 * sysinFileout.
 * </p>
 *
 * @throws java.lang.Throwable if any.
 */
@Test
public void sysinFileout() throws Throwable
{
    final String testName = Helper.testName();
    Helper.initializeFor(testName);

    final List<String> out = new ArrayList<>();
    out.add("line 1");
    out.add("line 2");

    final StringBuilder sb = new StringBuilder();
    for (final String outline : out)
        sb.append(outline).append(System.getProperty("line.separator"));
    final InputStream inputStream = new StringBufferInputStream(sb.toString());
    System.setIn(inputStream);

    final File file = Helper.outFileWhenInIsSysin();

    final FunnelContext context = Funnel.sort(Helper.config(), "-o" + file.getAbsolutePath()
            + " --row 2 -c original");

    Assert.assertEquals("records", 2L, context.getRecordCount());
    Helper.compare(file, out);
    Assert.assertTrue("delete " + file.getAbsolutePath(), file.delete());
}
 
開發者ID:fedups,項目名稱:com.obdobion.funnelsort,代碼行數:33,代碼來源:InputTest.java

示例8: getData

import java.io.StringBufferInputStream; //導入依賴的package包/類
private Vector getData(String a){
	//-- Put them together
	int x = 0;
	StringBuilder appletP	= new StringBuilder(128);
	String line	= thisApplet.getParameter("treedata" + x);
	while (line!=null){
		appletP.append( line.substring(1,line.length()-1) );
		x++;
		line	= thisApplet.getParameter("treedata" + x);
	}

	String appletParam	= appletP.toString();

	tags		= new Stack();
	params	= new Stack();
	StringBufferInputStream s = new StringBufferInputStream(appletParam);	

	try{
		parseXML(s);
	}catch(Throwable E){
		E.printStackTrace();
		return null;
	}

	return (Vector)params.peek();
}
 
開發者ID:OpenBD,項目名稱:openbd-core,代碼行數:27,代碼來源:TreeApplet.java

示例9: test_ConstructorLjava_io_InputStream

import java.io.StringBufferInputStream; //導入依賴的package包/類
/**
 * @tests java.io.StreamTokenizer#StreamTokenizer(java.io.InputStream)
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "StreamTokenizer",
    args = {java.io.InputStream.class}
)
public void test_ConstructorLjava_io_InputStream() throws IOException {
    st = new StreamTokenizer(new StringBufferInputStream(
            "/comments\n d 8 'h'"));

    assertEquals("the next token returned should be the letter d",
             StreamTokenizer.TT_WORD, st.nextToken());
    assertEquals("the next token returned should be the letter d",
             "d", st.sval);

    assertEquals("the next token returned should be the digit 8",
             StreamTokenizer.TT_NUMBER, st.nextToken());
    assertEquals("the next token returned should be the digit 8",
             8.0, st.nval);

    assertEquals("the next token returned should be the quote character",
             39, st.nextToken());
    assertEquals("the next token returned should be the quote character",
             "h", st.sval);
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:29,代碼來源:StreamTokenizerTest.java

示例10: testStreaming

import java.io.StringBufferInputStream; //導入依賴的package包/類
@Test
public void testStreaming() throws Exception {
    when(httpTransport.executeRequestGetStream(any(LightblueRequest.class),anyString())).
        thenReturn(new StringBufferInputStream(streamingResponse.replaceAll("'","\"")));
    LightblueClientConfiguration c = new LightblueClientConfiguration();
    try (LightblueHttpClient httpClient = new LightblueHttpClient(c, httpTransport)) {
        DataFindRequest findRequest = new DataFindRequest("test");
        findRequest.where(Query.withValue("a = b"));
        findRequest.select(Projection.includeField("foo"));
        ResultStream response=httpClient.prepareFind(findRequest);
        final List<JsonNode> docs=new ArrayList<JsonNode>();
        response.run(new ResultStream.ForEachDoc() {
                @Override
                public boolean processDocument(ResultStream.StreamDoc doc) {
                    docs.add(doc.doc);
                    return true;
                }
            });
        Assert.assertEquals(9,docs.size());
        
    }
}
 
開發者ID:lightblue-platform,項目名稱:lightblue-client,代碼行數:23,代碼來源:LightblueHttpClientTest.java

示例11: testNotStreaming

import java.io.StringBufferInputStream; //導入依賴的package包/類
@Test
public void testNotStreaming() throws Exception {
    when(httpTransport.executeRequestGetStream(any(LightblueRequest.class),anyString())).
        thenReturn(new StringBufferInputStream(nonStreamingResponse.replaceAll("'","\"")));
    LightblueClientConfiguration c = new LightblueClientConfiguration();
    try (LightblueHttpClient httpClient = new LightblueHttpClient(c, httpTransport)) {
        DataFindRequest findRequest = new DataFindRequest("test");
        findRequest.where(Query.withValue("a = b"));
        findRequest.select(Projection.includeField("foo"));
        ResultStream response=httpClient.prepareFind(findRequest);
        final List<JsonNode> docs=new ArrayList<JsonNode>();
        response.run(new ResultStream.ForEachDoc() {
                @Override
                public boolean processDocument(ResultStream.StreamDoc doc) {
                    docs.add(doc.doc);
                    return true;
                }
            });
        Assert.assertEquals(9,docs.size());
        
    }
}
 
開發者ID:lightblue-platform,項目名稱:lightblue-client,代碼行數:23,代碼來源:LightblueHttpClientTest.java

示例12: getUnicodeStream

import java.io.StringBufferInputStream; //導入依賴的package包/類
@SuppressWarnings("deprecation")
public InputStream getUnicodeStream(int columnIndex) throws SQLException {
    Object obj = getObject(columnIndex);
    if (obj == null) {
        return null;
    }
    if (obj instanceof byte[]) {
        return new StringBufferInputStream(new String((byte[]) obj));
    }

    if (obj instanceof String) {
        return new StringBufferInputStream((String) obj);
    }

    if (obj instanceof char[]) {
        return new StringBufferInputStream(new String((char[]) obj));
    }

    // rowset.10=Data Type Mismatch
    throw new SQLException(Messages.getString("rowset.10")); //$NON-NLS-1$
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:CachedRowSetImpl.java

示例13: testGetUnicodeStream_Not_Ascii

import java.io.StringBufferInputStream; //導入依賴的package包/類
public void testGetUnicodeStream_Not_Ascii() throws Exception {
    String value = new String("\u548c\u8c10");
    insertRow(100, value, null);
    rs = st.executeQuery("SELECT * FROM STREAM WHERE ID = 100");
    crset = newNoInitialInstance();
    crset.populate(rs);

    crset.next();

    assertTrue(crset.getObject(2) instanceof String);
    assertEquals(value, crset.getString(2));

    InputStream in = crset.getUnicodeStream(2);
    StringBufferInputStream sin = new StringBufferInputStream(value);

    int i = -1;
    while ((i = in.read()) != -1) {
        assertEquals(sin.read(), i);
    }

}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:CachedRowSetStreamTest.java

示例14: test_ConstructorLjava_io_InputStream

import java.io.StringBufferInputStream; //導入依賴的package包/類
/**
 * @tests java.io.StreamTokenizer#StreamTokenizer(java.io.InputStream)
 */
@SuppressWarnings("deprecation")
   public void test_ConstructorLjava_io_InputStream() throws IOException {
	st = new StreamTokenizer(new StringBufferInputStream(
			"/comments\n d 8 'h'"));

	assertEquals("the next token returned should be the letter d",
		     StreamTokenizer.TT_WORD, st.nextToken());
	assertEquals("the next token returned should be the letter d",
		     "d", st.sval);

	assertEquals("the next token returned should be the digit 8",
		     StreamTokenizer.TT_NUMBER, st.nextToken());
	assertEquals("the next token returned should be the digit 8",
		     8.0, st.nval);

	assertEquals("the next token returned should be the quote character",
		     39, st.nextToken());
	assertEquals("the next token returned should be the quote character",
		     "h", st.sval);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:24,代碼來源:StreamTokenizerTest.java

示例15: readObject

import java.io.StringBufferInputStream; //導入依賴的package包/類
private synchronized void readObject(java.io.ObjectInputStream oos) throws IOException, ClassNotFoundException
{		
	try
	{
		String wpsConfigXMLBeansAsXml = (String) oos.readObject();
		XmlObject configXmlObject = XmlObject.Factory.parse(wpsConfigXMLBeansAsXml);
		WPSConfigurationDocument configurationDocument = WPSConfigurationDocument.Factory.newInstance();
		configurationDocument.addNewWPSConfiguration().set(configXmlObject);
		wpsConfig = new WPSConfig(new StringBufferInputStream(configurationDocument.xmlText()));
	}
	catch (XmlException e)
	{
		LOGGER.error(e.getMessage());
		throw new IOException(e.getMessage());
	}
}
 
開發者ID:52North,項目名稱:uDig-WPS-plugin,代碼行數:17,代碼來源:WPSConfig.java


注:本文中的java.io.StringBufferInputStream類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。