File folderPathFile = new File("C:\\Users\\ali\\Desktop\\folderPath.txt");
BufferedReader reader = new BufferedReader(new FileReader(folderPathFile));
String line = reader.readLine();
while(line != null){
foldersPath.add(line);
line = reader.readLine();
}
reader.close();
String lineDup = line.toString();
String[] LineSplits = lineDup.split(",");
String[] array = LineSplits[1].trim().split(" ");
for(int i =0; i<array.length;i++) {
int fr = Integer.parseInt(array[i]);
System.out.println(fr);//its printing
}
int fr1 = Integer.parseInt(LineSplits[0]);
System.out.println(fr1);
}
내 문제는 내가이 코드를 실행할 때 java.lang.Exception: java.lang.NumberFormatException: For input string: "900"
INPUT i 'm Giving ie myfile 데이터는 900, 200300400500600
900 만 그런 오류가 발생하는 이유는 무엇입니까?
lineSplit [0] 길이가 4이면 보이지 않는 문자가 있습니다 (예 : ZERO WIDTH NO-BREAK SPACE) . 보이지 않고 트리밍이 해당 캐릭터를 삭제하지 않기 때문에 감지하기 어렵습니다. 그렇다면 해당 캐릭터를 제거해야합니다.
편집 : 길이가 4라고 말했듯이 이것을 시도 LineSplits[0].replace(u'\ufeff', '')
하거나 어딘가에서 복사하는 대신 해당 번호를 직접 쓸 수 있습니다.
HTML에 관한 것이지만 이 문자에 대한 긴 토론은이 SO 질문 에서 확인할 수 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다