Du verwendest einen veralteten Browser. Es ist möglich, dass diese oder andere Websites nicht korrekt angezeigt werden. Du solltest ein Upgrade durchführen oder ein alternativer Browser verwenden.
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;
}
kein Grund, bei einem Fehler eine andere API zu verlassen, die müsste auch gehen,
ohne Beschreibung, welche Eingabedaten und welche Fehler vorhanden sind,
kann man natürlich überhaupt nix sagen,
also ja, poste noch ne Main, statt ner Datei besser einen String oder ein String-Array im Programm mit den fraglichen Zeilen
und noch eine genaue Beschreibung wo was schiefläuft, was stattdessen zu erwarten ist usw.
while ((s = br.readLine()) != null){
// Now we read each individual line
int i = 0;
while (s.equals("END") == false){
StringTokenizer st = new StringTokenizer(s, ","); // s steht auf zeile ID
if (i == 0){
s = br.readLine(); // s hat jetzt die erste klammer gelesen
}
double x = Double.parseDouble(st.nextToken()); // peng, kaputt, token ist "ID"