Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import shipment of April 12, 2007
- # tab separated data
- Bird Golden Eagle Eddie
- Mammal Tiger Tommy
- Mammal Lion Leo
- Mammal Elephant Eddie
- Bird Parrot Polly
- # last one next
- Reptile Cobra Colin
- public void readDataFromFile() throws FileNotFoundException
- {
- fileName = fileDialogBox.getFile();
- String directoryPath = fileDialogBox.getDirectory();
- File dataFile = new File (fileName);
- Scanner scanner = new Scanner(dataFile);
- scanner.useDelimiter("\t");
- scanner.next();
- while(scanner.hasNextLine())
- {
- String type = scanner.next();
- String species = scanner.next();
- String name = scanner.next();
- System.out.println(type + " " + species + " " + name);
- scanner.nextLine();
- addAnimal( new Animal(species, name, this) );
- }
- scanner.close();
- }
- }
- boolean firstTime = true;
- while(scanner.hasNextLine())
- {
- if(firstTime)
- {
- scanner.nextLine();
- firstTime=false;
- }
- String type = scanner.next();
- String species = scanner.next();
- String name = scanner.next();
- System.out.println(type + " " + species + " " + name);
- scanner.nextLine();
- addAnimal( new Animal(species, name, this) );
- }
Add Comment
Please, Sign In to add comment