编写一个java程序,将用户从键盘输入的10个“字符”存入文件(.txt)不用输出 越简单越好 能实现就行

程序越精简越好 其他没要求

package addTIME;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class b {
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String a="";
try {
for(int i=1;i<=10;i++){
System.out.println("请输入字符"+i+":");
a=a+br.readLine();
}
FileOutputStream fout = new FileOutputStream("D:\\文件名.txt");//创建文件输出流对象fout,同时打开关联文件ceshi.txt,若文件不存在将新建一个
fout.write(a.getBytes());
fout.close();
} catch (IOException e) {
System.out.println("输入错误");
}
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-01-06
路过追问

真速度

追答

呵呵,我是完成任务的

第2个回答  2012-01-06
这从网上可以查到的,或找本教材。追问

我这有啊 程序是很简单 就是代码不够精简 我要考试时候手写的 所以尽量简单点

追答

你传一下,我试试,如何?

相似回答