package class8_1_FileIOBinaryVsText_start; import javafx.scene.paint.Color; import java.io.FileNotFoundException; import java.io.IOException; import java.nio.file.Paths; import java.util.LinkedList; import java.util.List; import java.util.Scanner; public class Point { private int x; private int y; private Color color; /** * * @param filename * @return * @throws FileNotFoundException if the point file cannot be found * @throws IOException if an unknown IO error occurs */ public static List loadPoints(String filename) throws FileNotFoundException, IOException { List points = new LinkedList(); Scanner fileScanner = null; // try { fileScanner = new Scanner(Paths.get(filename)); String numPointsLine = fileScanner.nextLine(); Scanner numPointsLineScanner = new Scanner(numPointsLine); int numPoints = numPointsLineScanner.nextInt(); for (int i = 0; i < numPoints; i++) { String pointLine = fileScanner.nextLine(); Scanner pointLineScanner = new Scanner(pointLine); double x = pointLineScanner.nextDouble(); double y = pointLineScanner.nextDouble(); String color = pointLineScanner.nextLine(); } //} /* catch(FileNotFoundException e) { // throw new FileNotFoundException("Warning: could not read points from: "+filename); //} */ return points; } }