当前位置: 首页>>代码示例>>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;未经允许,请勿转载。