当前位置: 首页>>代码示例>>Java>>正文


Java PipedReader.close方法代码示例

本文整理汇总了Java中java.io.PipedReader.close方法的典型用法代码示例。如果您正苦于以下问题:Java PipedReader.close方法的具体用法?Java PipedReader.close怎么用?Java PipedReader.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.PipedReader的用法示例。


在下文中一共展示了PipedReader.close方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PipedReader

import java.io.PipedReader; //导入方法依赖的package包/类
/**
 * @tests java.io.PipedReader#read(char[], int, int)
 */
public void test_read$CII() throws Exception {
    char[] c = null;
    preader = new PipedReader();
    t = new Thread(new PWriter(preader), "");
    t.start();
    Thread.sleep(500); // Allow writer to start
    c = new char[11];
    int n = 0;
    int x = n;
    while (x < 11) {
        n = preader.read(c, x, 11 - x);
        x = x + n;
    }
    assertEquals("Read incorrect chars", "Hello World", new String(c));
    try {
        preader.close();
        preader.read(c, 8, 7);
        fail("Failed to throw exception reading from closed reader");
    } catch (IOException e) {
        // Expected
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:26,代码来源:PipedReaderTest.java

示例2: PipedReader

import java.io.PipedReader; //导入方法依赖的package包/类
/**
 * @tests java.io.PipedReader#read(char[], int, int)
 */
public void test_read$CII() throws Exception {
       // Test for method int java.io.PipedReader.read(char [], int, int)
       char[] c = null;
       preader = new PipedReader();
       t = new Thread(new PWriter(preader), "");
       t.start();
       Thread.sleep(500); // Allow writer to start
       c = new char[11];
       int n = 0;
       int x = n;
       while (x < 11) {
           n = preader.read(c, x, 11 - x);
           x = x + n;
       }
       assertEquals("Read incorrect chars", "Hello World", new String(c));
       try {
           preader.close();
           preader.read(c, 8, 7);
           fail("Failed to throw exception reading from closed reader");
       } catch (Exception e) {
           // Correct
       }
   }
 
开发者ID:freeVM,项目名称:freeVM,代码行数:27,代码来源:PipedReaderTest.java

示例3: test_close

import java.io.PipedReader; //导入方法依赖的package包/类
/**
 * @tests java.io.PipedReader#close()
 */
public void test_close() throws Exception {
    char[] c = null;
    preader = new PipedReader();
    t = new Thread(new PWriter(preader), "");
    t.start();
    Thread.sleep(500); // Allow writer to start
    c = new char[11];
    preader.read(c, 0, 11);
    preader.close();
    assertEquals("Read incorrect chars", "Hello World", new String(c));
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:15,代码来源:PipedReaderTest.java

示例4: retryXsltTransformation

import java.io.PipedReader; //导入方法依赖的package包/类
private String retryXsltTransformation(ThreadContext context,
                                       IRubyObject[] args,
                                       DOMSource domSource,
                                       NokogiriXsltErrorListener elistener)
        throws TransformerException, IOException {
    Templates templates = getTemplatesFromStreamSource();
    Transformer transf = templates.newTransformer();
    transf.setErrorListener(elistener);
    if (args.length > 1) {
        addParametersToTransformer(context, transf, args[1]);
    }
    PipedWriter pwriter = new PipedWriter();
    PipedReader preader = new PipedReader();
    pwriter.connect(preader);
    StreamResult result = new StreamResult(pwriter);
    transf.transform(domSource, result);
    char[] cbuf = new char[1024];
    int len = preader.read(cbuf, 0, 1024);
    StringBuilder builder = new StringBuilder();
    builder.append(CharBuffer.wrap(cbuf, 0, len));
    htmlish = isHtml(builder.toString()); // judge from the first chunk
    
    while (len == 1024) {
        len = preader.read(cbuf, 0, 1024);
        if (len > 0) {
            builder.append(CharBuffer.wrap(cbuf, 0, len));
        }
    }
    
    preader.close();
    pwriter.close();
    
    return builder.toString();
}
 
开发者ID:gocd,项目名称:gocd,代码行数:35,代码来源:XsltStylesheet.java

示例5: test_close

import java.io.PipedReader; //导入方法依赖的package包/类
/**
 * @tests java.io.PipedReader#close()
 */
public void test_close() throws Exception {
    // Test for method void java.io.PipedReader.close()
    char[] c = null;
    preader = new PipedReader();
    t = new Thread(new PWriter(preader), "");
    t.start();
    Thread.sleep(500); // Allow writer to start
    c = new char[11];
    preader.read(c, 0, 11);
    preader.close();
    assertEquals("Read incorrect chars", "Hello World", new String(c));
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:16,代码来源:PipedReaderTest.java

示例6: testGetInfo

import java.io.PipedReader; //导入方法依赖的package包/类
/**
 * Test sysinfo.getInfo()
 *
 * Currently only tests getInfo() by comparing the first line with the
 * expected first line in English. Because so much of sysinfo changes from
 * machine-to-machine, writing a better test may be difficult.
 *
 * Test spawns a separate thread in which to call sysinfo and feed the
 * PipedWriter. Using PipedWriter and PipedReader from the same thread
 * can cause a deadlock.
 */
public void testGetInfo() throws IOException {
    sysinfo_api_helper sah = new sysinfo_api_helper();
    sah.start();
    PipedReader pipeR = new PipedReader(sah.getPipedWriter());
    BufferedReader br = new BufferedReader(pipeR);
    assertEquals("------------------ Java Information ------------------",
                 br.readLine());
    br.close();
    pipeR.close();
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:22,代码来源:SysinfoAPITest.java


注:本文中的java.io.PipedReader.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。