I try to convert a file to an array of integers, do not know where my mistake is that when I print the array empty array throws
I leave my method , thanks you
public int[] ConvertToArray(File xd) throws IOException {
String sCadena;int i=0;
int[]array;
FileReader fr = new FileReader(xd);
BufferedReader bf = new BufferedReader(fr);
int lNumeroLineas = 0;
while ((sCadena = bf.readLine())!=null) {
lNumeroLineas++;
}
array = new int[lNumeroLineas];
while ((sCadena = bf.readLine())!=null) {
lNumeroLineas++;
array[i]=Integer.parseInt(sCadena);
i++;
}
for (int j = 0; j < array.length; j++) {
System.out.println(array[i]);
}
return array;
}