Hallo zusammen,
ich suche vergeblich nach dem Fehler! Nach mir müsste es funktionieren...
(Wenn ihr die zusätzlichen Codes (Tester mit main-Methode und das Textfile) wollt einfach melden)
hier mein Code (die Methode readCoastLine aus der Klasse Reader):
Liebe Grüsse
Sascha
ich suche vergeblich nach dem Fehler! Nach mir müsste es funktionieren...
(Wenn ihr die zusätzlichen Codes (Tester mit main-Methode und das Textfile) wollt einfach melden)
hier mein Code (die Methode readCoastLine aus der Klasse Reader):
Code:
/**
* A static method to read in the Coastline.txt files.
*
* @param fileName A file from which to read the coast line's geometry from.
* @return Hashtable A Hashtable containing Point objects representing a coast line.
*/
public static Vector<Point> readCoastLine(String fileName) throws Exception{
Vector<Point> points = new Vector<Point>();
// All the steps we need to create a buffered reader to read this file
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(fileName))));
// Now we will read the file.
// The format is as follows
// ID
// x,y
// (... this group of points represents a line with an ID)
// x,y
// END
// ID
// x,y
// ...
// x,y
// END
// END
// The first loop reads every line from the file. Since we don't need each individual coast line segment-id we skip this line.
String s;
while ((s = br.readLine()) != null){
// Now we read each individual line
int i = 0;
while (s.equals("END") == false){
StringTokenizer st = new StringTokenizer(s, ",");
if (i == 0){
s = br.readLine();
}
double x = Double.parseDouble(st.nextToken());
double y = Double.parseDouble(st.nextToken());
Point p = new Point(x,y);
points.add(p);
i++;
s = br.readLine();
}
}
return points;
}
Sascha