Code example for PipedInputStream

Methods: read

0
            return reader;
        } 
 
        public PReader(PipedOutputStream out) {
            try { 
                reader = new PipedInputStream(out);
            } catch (Exception e) {
                System.out.println("Couldn't start reader");
            } 
        } 
 
        public int available() { 
            try { 
                return reader.available();
            } catch (Exception e) {
                return -1; 
            } 
        } 
 
        public void run() { 
            try { 
                while (true) { 
                    Thread.sleep(1000);
                    Thread.yield();
                } 
            } catch (InterruptedException e) {
            } 
        } 
 
        public String read(int nbytes) {
            byte[] buf = new byte[nbytes];
            try { 
                reader.read(buf, 0, nbytes);
                return new String(buf, "UTF-8");
            } catch (IOException e) {
                System.out.println("Exception reading info");
                return "ERROR"; 
            } 
Connect your IDE to all the code out there  Get Codota for Java