我使用字符串的數組[3]來存儲其從4個JTextField的 我然後輸出該陣列到一個txt文件得到的用戶輸入:陣列「出界」
String[] userInfo = new String[3];
userInfo[0] = sourceTextField.getText();
userInfo[1] = usernameTextField.getText();
userInfo[2] = passwordTextField.getText();
userInfo[3] = emailTextField.getText();
for (String userInfo1 : userInfo) {
try
{
BufferedWriter writer = new BufferedWriter(new FileWriter("C:\\Users\\Peace Infinity\\Desktop\\[programming]Projects\\DataFiles\\PasswordRepository.txt", true));
String s;
s = userInfo1;
writer.write(s + " ");
writer.flush();
}catch (IOException ex)
{
Logger.getLogger(ADD_dialogBox_v1.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(null, "Error processing file!");
}
}
可有人告訴我爲什麼我得到異常「數組索引越界」? 謝謝
謝謝,我得到它的工作..它實際上是一個愚蠢的問題。抱歉。 – noBrainer 2014-09-22 21:17:21