Code example for PipedInputStream

Methods: read

0
        } 
 
        public String read(int nbytes) {
            byte[] buf = new byte[nbytes];
            try { 
                reader.read(buf, 0, nbytes);
                return new String(buf);
            } catch (IOException e) {
                System.out.println("Exception reading ("
                        + Thread.currentThread().getName() + "): "
                        + e.toString());
                return "ERROR"; 
            } 
        } 
    } 
 
    static final String testString = "Lorem ipsum dolor sit amet,\n" +
        "consectetur adipisicing elit,\nsed do eiusmod tempor incididunt ut" + 
        "labore et dolore magna aliqua.\n"; 
    static final int testLength = testString.length();