-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStandardOutput.java
More file actions
48 lines (41 loc) · 1.54 KB
/
Copy pathStandardOutput.java
File metadata and controls
48 lines (41 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package src.thinkinginjava.IO18;
import java.io.*;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Ryan on 2017/3/21.
*/
public class StandardOutput {
public static void main(String[] args) throws IOException {
/**
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
src.thinkinginjava.String13 s;
while ((s = bufferedReader.readLine()) != null && s.length() != 0)
System.out.println(s.toUpperCase());
*/
/**
Scanner scanner = new Scanner(System.in);
while (scanner.hasNextLine())
System.out.println(scanner.nextLine());
*/
PrintWriter printWriter = new PrintWriter(System.out, true);
printWriter.println("hello");
PrintStream printStream = System.out;
PrintStream printStream1 = new PrintStream(new BufferedOutputStream(new FileOutputStream(".")));
System.setOut(printStream1);
System.setOut(printStream);
Process process = new ProcessBuilder("").start();
process.getInputStream();
process.getOutputStream();
process.getErrorStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String s;
List<String> list = new ArrayList<>();
while ((s = bufferedReader.readLine()) != null) {
System.out.println(s);
list.add(s);
}
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(1024);
}
}