我已经编写了这个程序来将标记写入名为 的文件marks.txt
中,但是为什么dos.writeInt()
将 Ascii 值写入文件中?
class Q5marks
{
public static void main(String a[])throws IOException`
{
int marks[]=new int[6]
File file = new File("marks.txt");
FileOutputStream fos = new FileOutputStream(file);
DataOutputStream dos = new DataOutputStream(fos);
Scanner sc = new Scanner(System.in);
for(int i = 0;i<6;i++)
{
marks[i]=sc.nextInt();
System.out.println("marks "+(i+1)+" =>" +marks[i]);
dos.writeInt(marks[i]);
}
}
}