just started programming with Java. If I have an array as follows stored in a .txt file:
[10, 22, 30, 55, 10, 20, 19]
How do I convert it back to a normal int[] array to be used within the code?
I need to be able to store it plainly in a txt file like this so I can make changes to it manually. I've used BufferedReader to read the array. How can I put the read array into an int[] array?
int[] field;
try {
String line;
br = new BufferedReader(new FileReader(gameFilePath));
while((line = br.readLine()) != null) { // Read the first line and assume it is the stored array
field = line;
System.out.println("-------------------------------------------------------------------");
System.out.println(line);
}
} catch(IOException e) {
e.printStackTrace();
}