› Foros › PC › Software libre
public static List<Vector<Float>> readFile(String file, String separator)
throws FileNotFoundException, IOException {
Vector <Float> row = new Vector <Float>();
List <Vector <Float>> dataset = new ArrayList<Vector <Float>>();
BufferedReader br = new BufferedReader (new FileReader (file));
Float i;
String line = br.readLine();
while (line != null)
{
String token;
StringTokenizer st = new StringTokenizer(line, separator);
while (st.hasMoreTokens()) {
token = st.nextToken();
i = new Float(token);
row.addElement(i);
}
dataset.add(row);
row.clear(); //aqui limpio la fila
line = br.readLine();
}
System.out.println(dataset);
br.close();
return dataset;
}