import java.io.*;
public class read_stdin{
public static void main(String[] args) {
DataInputStream in = new DataInputStream(new BufferedInputStream(System.in));
String s;
try {
while((s = in.readLine()).length() != 0)
System.out.println(s);
//An empty line terminates the program
} catch(IOException e) {
e.printStackTrace();
}
}
}
public class read_stdin{
public static void main(String[] args) {
DataInputStream in = new DataInputStream(new BufferedInputStream(System.in));
String s;
try {
while((s = in.readLine()).length() != 0)
System.out.println(s);
//An empty line terminates the program
} catch(IOException e) {
e.printStackTrace();
}
}
}
本文提供了一个Java程序示例,演示了如何从标准输入流中读取文本行,并将其打印到控制台。该程序使用DataInputStream和BufferedInputStream处理输入,直到遇到空行为止。
2111

被折叠的 条评论
为什么被折叠?



