1. 程序如下:
package com.xuzhiwen.io1;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileOutputStreamTest {
public static void main(String[] args)
throws IOException {
System.out.println("please input :"
);
byte b[] =
new byte[1024
];
int count =
System.in.read(b); //如果不存在test.txt则会创建该文件,如果存在则覆盖
FileOutputStream out =
new FileOutputStream("test.txt"
);
out.write(b, 0
, count);
out.close();
System.out.println("save success"
);
}
}
2.运行程序,输入:hello world
3.查看结果:
转载于:https://www.cnblogs.com/beibidewomen/p/7358461.html
相关资源:数据结构—成绩单生成器