public class Snippet {
public void output() throws IOException {
FileWriter fw = new FileWriter("D://stu.txt");
BufferedWriter bw = new BufferedWriter(fw);
bw.write("name" + "score1" + "score2" + "score3");
bw.newLine();
for (int i = 0; i < 5; i++) {
bw.write(" " + "asdasd");
for (int j = 0; j < 3; j++) bw.write("" +j);
bw.newLine();
}
bw.close();
}
public static void main(String[] args) throws IOException {
new Snippet().output();
}
}
试了试,没有任何问题 |