Analyzing a line of a text file
I'm quite new to Java, but I've already completed an Android project. I now started on a Java project, but an error has been occuring for a long time. I have tried to find the reason, but couldn't succeed. As my last resource I would like to ask you if you know what might go wrong.
I basically have a text file, consisting out of many X and Y points enclosed by square brackets. A name can be added behind the points, but is not always the case. A fragment:
As you've probably guessed, I want to read the numbers and additional names into my application. To do this, I've written this relatively small piece of code:
The initialization of the variables used has been done before.
FileReader file = new FileReader("C:\\maps2\\"+i+"\\"+i2+".mada");
BufferedReader reader = new BufferedReader(file);
line = reader.readLine();
line2 = line;
ways[ways_length] = new double[line.replaceAll("[^\\", "").length()];
count = 0;
begin = line.indexOf("[")+1;
end = line.indexOf("]");
if (line.substring(begin, end).equals("50631700"))
ways[ways_length][count] = Double.parseDouble(line.substring(begin, end))/lonlat_multiplier;
line = line.replace(line.substring(begin-1, end+1), "");
if (line.length() > 0)
ways_name[ways_length] = line;
Everything's read correctly, and even displayed correctly (the code for that, I haven't shown). However, at a few lines (each run the same ones) it looks like count remains the same. In other words, the line "count ++;" isn't executed (so it looks).
This is one of the lines where it goes wrong:
ways[ways_length] is first set to 5.0631700 then 1 loop later to 52.6502500 although this value should be assigned to ways[ways_length].
I can't figure out why this is happening and I'm hoping one of you could help me. If you need more information I'd be happy to add some more.