public class PrintIOTest {
public static void main(String[] ages){
try{
FileOutputStream fos = new FileOutputStream("test.txt");
PrintStream ps = new PrintStream(fos);
ps.print("hello,world!");
}catch (FileNotFoundException e){
e.printStackTrace();
}
/*try{
FileWriter fw = new FileWriter("test.txt");
PrintWriter pw = new PrintWriter(fw);
pw.write("你好");
}catch(IOException e){
e.printStackTrace();
}*/
}
}
用字节流外面套一个PrintStream运行正常,但是换成注释里的内容却只能新建test.tex,而不写内容,请问是怎么回事??