When I run program it never stops, and don't know how to make (for each line) different v number (gives me syntax error) thanks for helping. file format each line has string int string string
public static void main(String[] args) throws FileNotFoundException, IOException {
String filelocation = "location";
filelocation = JOptionPane.showInputDialog("Enter file address");
BufferedReader inFile = new BufferedReader(new FileReader(filelocation)); //using BufferedReader to get readLine function
ArrayList<Vehicle> VehicleList = new ArrayList<Vehicle>();
int counter = 1;
String dataRow = null;
dataRow= inFile.readLine();
while ( dataRow != null){
try{
String[] temp = dataRow.trim().split("\\s+");
Vehicle v(counter) = new Vehicle (temp[0], Integer.parseInt(temp[1]), temp[2], temp[3], temp[4]);
VehicleList.add(v1);
dataRow= inFile.readLine();
}
catch(Exception e){}
}
inFile.close();
System.out.println(VehicleList);
System.out.println(v1);
}
e.printStackTrace()in your catch block, and you'll see whats really happening.v1? If it's inside the loop (which it definitely should be), then that lastSystem.out.printlnisn't going to compile. But I don't see a declaration of it anywhere.