Java Input Redirection ?


在學校中遇到的問題..多得一位同學的幫忙 @_@ 解決

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
* java xxx < xxx.java
* or
* java xxx
*/
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class test{
public static void main(String[] args) throws IOException {
StringBuilder data = new StringBuilder();

do {
System.out.print("Type something: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
while(line != null && !line.equals("__END__")) { data.append(line); line = br.readLine(); }
}while (data.length() <= 0);

System.out.println("You typed: " + data);
}
}