I have a text file that contains one number, and I'm loading it using this method:
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader("res/sheet.cfg"));
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
try {
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line);
sb.append('\n');
line = br.readLine();
}
textureSize = Integer.valueOf(sb.toString());
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
This line:
textureSize = Integer.valueOf(sb.toString());
Throws this error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "16"
I understand what the issue is, but how do I fix it? Do I need to create a temporary string to remove the quotations and then get the value of that string and pass it into textureSize?