java的io流问题
import java.io.*;
public class FileOutputStreamDemo{
public static void main(String[] args){
FileOutputStream fos;
int filesize;
byte[] buf = new byte[1024];
System.out.println("please input some contents :");
try{
filesize = System.in.read(buf);
fos = new FileOutputStream("myfile2.txt");
fos.write(buf);
fos.flush();
fos.close();
}catch(IOException e){
System.out.println(e.getMessage());
}
}
}
代码编译没问题,也能够运行,在指定的地方创建了myfile2.txt文件。但是在控制台获取的信息却没有出现在该创建的文件里面。里面就只有一个please input some contents !请问是怎么会是啊?为什么没有显示我在控制台输入的信息?