-1
在Java中我嘗試將字符串值轉換爲整數,除去4個最後一個字符,所以我想這樣的:的Java:一個字符串轉換爲INT(來源不明)
String filename1="98597598684.txt";
int id = Integer.parseInt(filename1.substring(0, filename1.length()-4));
,但我得到這個錯誤,我不明白爲什麼:
java.lang.NumberFormatException: For input string: "98597598684"
at java.lang.NumberFormatException.forInputString(Unknown Source)
它可能是簡單的,但這使我瘋狂,因爲1小時,任何想法?
重複:http://stackoverflow.com/questions/27331336/java-lang-numberformatexception-invalid-int-3546504756-what-does-this-error, http://stackoverflow.com/questions/31846838/integer-parsestring-str-java-lang-numberformatexception-errors – rgettman
尋求解決方案的提示:在這種情況下,如果您有的話,您可能會在一小時內找到答案在「java.lang.NumberFormatException.forInputString」**上搜索「」。這爲我生成這個現有的stackoverflow線程作爲第一次打擊:http://stackoverflow.com/questions/13935167/java-lang-numberformatexception-for-input-string。例外是你的朋友,谷歌他們的生活日光:) – Gimby