import java.io.*; import java.util.*; public class IO { public double[][] readData() { File f = new File("coordinates.txt"); FileReader fr = null; try { fr = new FileReader (f); } catch (FileNotFoundException fnfe) { fnfe.printStackTrace(); } BufferedReader br = new BufferedReader(fr); int lines = -1; String textIn = ""; String[] file = null; try { while (textIn != null) { textIn = br.readLine(); lines++; } file = new String[lines]; br.close(); try { fr = new FileReader (f); } catch (FileNotFoundException fnfe) { fnfe.printStackTrace(); } br = new BufferedReader(fr); for (int i = 0; i < lines; i++) { file[i] = br.readLine(); } br.close(); } catch (IOException ioe) { ioe.printStackTrace(); } double[][] data = new double [lines][]; for (int i = 0; i < lines; i++) { StringTokenizer st = new StringTokenizer(file[i],","); data[i] = new double[st.countTokens()]; int j = 0; while (st.hasMoreTokens()) { data[i][j] = Double.parseDouble(st.nextToken()); j++; } } return data; } }