public void Save()
{
DataOutputStream out = null;
try {
out = new DataOutputStream(new FileOutputStream("D:\pcb-input.txt"));
} catch (FileNotFoundException e1)
{}
int i;
for(i=0;i<sum;i++)
{
//輸出PCB信息
try {
out.writeInt(PCBS[i].ProID);
out.writeInt(PCBS[i].Priority);
out.writeLong(PCBS[i].InTimes);
out.writeInt(PCBS[i].InstrucNum);
for(int j=0;j<PCBS[i].InstrucNum;j++)
{
out.writeInt(PCBS[i].Instrc[j].Instruc_ID);
out.writeInt(PCBS[i].Instrc[j].Instruc_State);
out.writeDouble(PCBS[i].Instrc[j].Instruc_Times);
}
} catch (IOException e) {}
}
try {
out.flush();
out.close();
} catch (IOException e)
{}
![圖片](http://img.ask.csdn.net/upload/201511/03/1446552569_554429.jpg)
沒有問題,因為你直接寫的是int,讀取出來自然是亂碼。記事本按照ascii而不是實際的值理解數據。沒問題,你寫的是對的。
如果你希望寫進去的可讀,需要用writeString(整數.toString());