Skip to content

Commit e0ebdef

Browse files
committed
PipeStream example
1 parent d756749 commit e0ebdef

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Diff for: java-11/PipeStreamTest.java

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.github.wesleyegberto.api.io;
2+
3+
import java.io.*;
4+
5+
public class PipeStreamTest {
6+
public static void main(String[] args) throws Exception {
7+
var writer = new StringWriter();
8+
var inputPipe = new PipedInputStream();
9+
var inputBuffed = new BufferedInputStream(inputPipe);
10+
11+
var outputPipe = new PipedOutputStream(inputPipe);
12+
var outputBuffered = new BufferedOutputStream(outputPipe);
13+
14+
var w = new PrintWriter(outputBuffered);
15+
w.write("Hello Bug");
16+
w.flush();
17+
w.close();
18+
19+
System.out.println(new String(inputBuffed.readAllBytes()));
20+
}
21+
}

0 commit comments

Comments
 (0)