I need to parse integers from contents of a file.
For testing my algorithms, when I give the contents of a file from a declared string
String test = "15 kuruş";
Integer.parseInt works fine. But when I read with Scanner class from a UTF-8 file it doesn't work and gives the exception
java.lang.NumberFormatException: For input string: "15"
Note: I split the string to "15" and "kuruş" so the parseInt method takes only "15" as argument.
Sample code:
satir = satir.trim();//15 kuruş
StringTokenizer tokenizer = new StringTokenizer(satir," ");
System.out.println(tokenizer.countTokens());//2
String s = tokenizer.nextToken();
int deger = Integer.parseInt(s);//where the exception was throwed