1
我在將2d用戶輸入數組寫入文本文件時遇到問題。我的代碼迄今(在保存方法,至少)是:Java:調用WriteUTF方法時出錯
`public static void Save(String[][] EntryList)
{
try {
String[][] content = EntryList;
File file = new File("CBB.dat");
// if file doesnt exists, then create it
if (!file.exists()) {
file.createNewFile();
}
InputStream instream;
OutputStream outstream;
instream = new DataInputStream(new BufferedInputStream(new FileInputStream(file))); // buffers the data stream
outstream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
FileWriter fw = new FileWriter(file.getAbsoluteFile(), true);
BufferedWriter writer = new BufferedWriter(fw);
for (int row = 0; row < EntryList.length; ++row)
{
outstream.writeUTF(EntryList[row][1]);
outstream.writeUTF(EntryList[row][2]);
outstream.writeUTF(EntryList[row][3]);
outstream.writeUTF(EntryList[row][4]);
outstream.writeUTF(EntryList[row][5]);
}
outstream.close();
}catch (IOException e) {
e.printStackTrace();
}
}`
然而,當我嘗試編譯,我得到了錯誤的Java「無法找到符號 - 方法WriteUTF(字符串)」
它現在正在工作,愚蠢的我不注意到這一點。非常感謝! – LP7665 2013-03-16 15:28:08