帮我看看这个简单的问题..!
import java.io.*;
public class temp
{
public static void main(String [] args)
{
try
{
String head = "Name,ID,DS,DB";
byte[] c = new byte[40];
c = head.getBytes();
System.out.println(new String(c));
String record = "\n";
BufferedWriter fo = new BufferedWriter(new FileWriter("c:\\student.txt",true));
String[] info = new String[4];
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < info.length; i++)
{
info[i] = reader.readLine();
record += info[i];
}
System.out.println(record);
fo.write(record);
fo.close();
}
catch (FileNotFoundException fe)
{
System.out.println("File Not Found");
}
catch (IOException ie)
{
System.out.println("IO Exception");
}
}
}
我想让程序实现输出字符保存到文本文件里
其格式为
Name,ID,DS,DB
a 001 90 90
b 002 90 96
当我输入两组数据以后,程序执行结果与预期结果不同,我搞了半天也没搞懂为什么,
a 001 90 90b 002 99 99null
nullnullnullnull
上面为程序执行,为什么会是这种结果