I'm having slight trouble converting a string which I am reading from a file into a multidimensional int array having found what I believe are suggestions here.
See this file here for string content.
Essentially I would like to replace the CR and LF so as to create a multi dimensional int array.
As per my code below where could I be going wrong?
public static void fileRead(String fileContent) {
String[] items = fileContent.replaceAll("\\r", " ").replaceAll("\\n", " ").split(" ");
int[] results = new int[items.length];
for (int i = 0; i < items.length; i++) {
try {
results[i] = Integer.parseInt(items[i]);
System.out.println(results[i]);
} catch (NumberFormatException nfe) {};
}
}
EDIT: I'm not encountering any errors. The above logic only creates an int array of size two i.e. results[0] = 5 and results[ 1] = 5
Thanks for any suggestions.