最好在这里使用扫描仪:
static class State {
int in;
int out;
String symbol;
State(int in, int out, String symbol) {
this.in = in;
this.out = out;
this.symbol = symbol;
}
@Override
public String toString() {
return in + " " + out + " " + symbol;
}
}
public static void main(String[] args) throws FileNotFoundException {
Scanner s = new Scanner(new File("input.txt"));
int startState = Integer.parseInt(s.nextLine());
List<Integer> acceptStates = new LinkedList<Integer>();
List<State> states = new LinkedList<State>();
Scanner st = new Scanner(s.nextLine());
while (st.hasNextInt())
acceptStates.add(st.nextInt());
while (s.hasNextInt())
states.add(new State(s.nextInt(), s.nextInt(), s.next()));
System.out.println(startState);
System.out.println(acceptStates);
System.out.println(states);
// logic...
}