I have been looking for the answer to this problem for a good while now since it seems most of the times its something simple. I am trying to read line by line of a file and on some instances convert the string into a number. When i write my code the Interger.parseInt
simply doesnt work. I have tried everything from changing the scope of the varaible to leaving it as a string then converting after finishing the loop but it simply says Interger
in Interger.parseInt
cannot be found.
package inputout;
import java.io.*;
import java.util.*;
import static java.lang.Integer.parseInt;
public class readfilebuffer {
private String Resname;
private int numberTables;
private int[] maxpertable;
private int[] sbm;
private String[] line4;
public void readFile1(File fin) throws FileNotFoundException {
int count = 0;
try {
FileReader fileReader = new FileReader(fin);
BufferedReader bufferedReader = new BufferedReader(fileReader);
String line;
while ((line = bufferedReader.readLine()) != null) {
if(count==0 )
Resname = line;
if(count==1)
numberTables = Interger.parseInt(line);//Interger here "cannot be found"
}
fileReader.close();
System.out.println(numberTables);
} catch (IOException e) {
e.printStackTrace();
}
}
}
and at count==1
i have this line being read in 4
and when i print the value in numberTablles
is 0.