If you need your files to be in that format so that you can open them in a text editor then I would use a BufferedReader to read the file then read in each line as a string and split the line first at each space then at each comma, then parse the string to return your number.
try(BufferedReader in = new BufferedReader(new FileReader("file"))){
String line;
while((line=in.readLine())!=null){
String[] values = line.split(" ");
for(String v:values){
String[] coords = v.split(",");
int x = Integer.parseInt(coords[0]);
int y = Integer.parseInt(coords[1]);
}
However an easier way to do this may be to simply write the int values directly from your map editor instead of converting them to strings. If you do this then you would save space and all you would need to do to read the data is:
try(DataInputStream in= new DataInputStream(new BufferedInputStream(new FileInputStream(new File("file"))))){
int numValues=in.readInt();
for(int i=0;i<numValues;i++){
int x = in.readInt();
int y = in.readInt();
}
}
And in your map editor to save the map you would just write the number of tiles to the file and then each of the tiles' x and y coordinates with writeInt()
and a DataOutputStream.
You may also want to write the width and height of the map to the file so that you can reconstruct it if those are not constant, or the coordinates of the tile on the map.