List of usage examples for java.io PipedReader PipedReader
public PipedReader(int pipeSize)
PipedReader
so that it is not yet #connect(java.io.PipedWriter) connected and uses the specified pipe size for the pipe's buffer. From source file:Main.java
public static void main(String[] args) { PipedWriter writer = new PipedWriter(); PipedReader reader = new PipedReader(100); try {/*from ww w .j a v a2 s. co m*/ // connect the reader and the writer reader.connect(writer); writer.write(70); writer.write(71); // check if reader is ready to read System.out.println(reader.ready()); // print the char array for (int i = 0; i < 2; i++) { System.out.println("" + (char) reader.read()); } } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {// w w w. j av a 2 s. com PipedWriter writer = new PipedWriter(); PipedReader reader = new PipedReader(writer); // connect the reader and the writer reader.connect(writer); writer.write(70); writer.write(71); // check if reader is ready to read System.out.println(reader.ready()); // print the char array for (int i = 0; i < 2; i++) { System.out.println("" + (char) reader.read()); } reader.close(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) throws IOException { PipedWriter pw = new PipedWriter(); PipedReader pr = new PipedReader(pw); int ch;/*from ww w.j a v a 2 s. c o m*/ try { for (int i = 0; i < 15; i++) pw.write(" A" + i + '\n'); while ((ch = pr.read()) != -1) System.out.print((char) ch); } catch (IOException e) { } }
From source file:MyThread.java
public static void main(String[] args) throws Exception { PipedWriter pw = new PipedWriter(); PipedReader pr = new PipedReader(pw); MyThread mt1 = new MyThread("src", pr, pw); MyThread mt2 = new MyThread("dst", pr, pw); mt1.start();/*from ww w .ja va 2 s .com*/ Thread.sleep(2000); mt2.start(); }
From source file:PipedCharacters.java
public static void main(String[] args) { try {/*from w w w. j a v a 2s. c o m*/ final PipedWriter out = new PipedWriter(); final PipedReader in = new PipedReader(out); Runnable runA = new Runnable() { public void run() { writeStuff(out); } }; Thread threadA = new Thread(runA, "threadA"); threadA.start(); Runnable runB = new Runnable() { public void run() { readStuff(in); } }; Thread threadB = new Thread(runB, "threadB"); threadB.start(); } catch (IOException x) { x.printStackTrace(); } }
From source file:Sender.java
public Receiver(Sender sender) throws IOException { in = new PipedReader(sender.getPipedWriter()); }
From source file:RhymingWords.java
public static Reader reverse(Reader source) throws IOException { BufferedReader in = new BufferedReader(source); PipedWriter pipeOut = new PipedWriter(); PipedReader pipeIn = new PipedReader(pipeOut); PrintWriter out = new PrintWriter(pipeOut); new ReverseThread(out, in).start(); return pipeIn; }
From source file:RhymingWords.java
public static Reader sort(Reader source) throws IOException { BufferedReader in = new BufferedReader(source); PipedWriter pipeOut = new PipedWriter(); PipedReader pipeIn = new PipedReader(pipeOut); PrintWriter out = new PrintWriter(pipeOut); new SortThread(out, in).start(); return pipeIn; }
From source file:com.sonicle.webtop.mail.SaxHTMLMailParser.java
public void initialize(HTMLMailData mailData, boolean justBody) throws SAXException { //if (writer!=null || reader!=null) throw new SAXException("SaxHTMLMailParser yet not released!"); release();// w w w. j av a 2 s. co m this.mailData = mailData; writer = new PipedWriter(); try { reader = new PipedReader(writer); } catch (IOException exc) { throw new SAXException(exc); } pwriter = new PrintWriter(writer); breader = new BufferedReader(reader); this.justBody = justBody; }
From source file:com.daveoxley.cbus.CGateSession.java
private BufferedReader getReader(String id) throws CGateException { try {//from w ww . j ava 2 s. c o m PipedWriter piped_writer = new PipedWriter(); BufferedWriter out = new BufferedWriter(piped_writer); response_writers.put(id, out); PipedReader piped_reader = new PipedReader(piped_writer); return new BufferedReader(piped_reader); } catch (IOException e) { throw new CGateException(e); } }