I am trying to read in from a .dat file, which includes a list of names a line of asterisks and a list of numbers, JUST the names in the file into nodes to be used in a linked list. All of the names will be before the line of asterisks. I am using Scanner to read in from the file. How exactly should I read in the names and use them in the Node class?
import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;
public class Main {
public static void main(String[] args) throws FileNotFoundException {
Scanner input = new Scanner(new File("lab2.dat"));
int size = 0;
Node first = new Node(null, null);
LinkedList survive = new LinkedList(first, size);
while(input.hasNext()){
//???
}//end while
System.out.println(size);
}//end main
}//end Main class
public class Node {
private String name;
private Node next;
Node(){
immunity = false;
}
Node(String d, Node n){
name = d;
next = n;
}
public void setName(String d){
name = d;
}
public String getName(){
return name;
}
public void setNext(Node n){
next = n;
}
public Node getNext(){
return next;
}
}//end Node Class