我正在處理類項目的密碼登錄部分。沒有什麼花哨。用戶或角色將是一個int並且密碼是一個String。我現在只是使用簡單的加密。我遇到的問題是在讀取文件時遇到輸入不匹配。過去我做了類似的事情,需要我閱讀整數和字符串,並沒有任何問題。但我無法弄清楚在這種情況下出了什麼問題。任何幫助,爲什麼我得到這個錯誤將不勝感激。我正在使用while(inputStream.hasNextLine())
,然後閱讀int
,然後String
我試過hasNextInt
和hasNext
,並一直得到相同的錯誤。從txt文件加載int和加密的字符串
public void readFile(){
Scanner inputStream = null;
try {
inputStream = new Scanner (new FileInputStream("login.txt"));
}catch (FileNotFoundException e) {
e.printStackTrace();
}
if(inputStream != null){
while (inputStream.hasNextLine()){
int luser = inputStream.nextInt();
String lpass = inputStream.nextLine();
newFile[count] = new accessNode(luser, lpass);
count ++;
}
inputStream.close();
}
}
你需要上傳你要得到很好的幫助實際的錯誤 - I,E,實際的錯誤消息,說明該線失敗和堆棧跟蹤。 –