从键盘终端依次输入
a
b
c
d
e
然后要在屏幕上看到
a
b
c
d
e
这样的输出
public static void main(String[] args) {
File f=new File("f:"+File.separator+"abc.txt");
try {
OutputStream fout=new FileOutputStream(f);
OutputStream out=System.out;
Scanner scan=new Scanner(System.in);
PrintStream ps=new PrintStream(fout);
String content;
while(true){
content=scan.nextLine();
ps.print(content);
if(content==null){
break;
}
//out.write(content.getBytes());
}
out.write(content.getBytes());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
我目前出现的问题是不能在输入完所有的字母之后,一次性的在屏幕上显示
a
b
c
d
e
这样的输出。只是输入一个a屏幕上就输出一个a
希望有大佬看到后,帮忙想想解决办法,谢谢啦