while(fileSource.hasNextLine()) { r = fileSource.nextLine(); if(r.charAt(0) == '#') // Check if the line is a comment { continue; // If it is, then skip this line } else // Else create the car! { String[] carDetails = r.split("\\s"); Car car = new Car(carDetails[0], Float.parseFloat(carDetails[1]), Float.parseFloat(carDetails[2])); ferryInfo.loadFerry(car); } }