private Automaton readAutomaton(File file) {
		try {
			BufferedReader reader = new BufferedReader(new FileReader(file));
			// Read the automaton type.
			String line = reader.readLine().trim();
			if (line.equals(FINITE_AUTOMATON_CODE))
				return readFA(reader);
			if (line.equals(PUSHDOWN_AUTOMATON_CODE))
				return readPDA(reader);
			if (line.equals(TURING_MACHINE_CODE))
				return readTM(reader);
			throw new ParseException("Unknown machine type " + line + "!");
		} catch (NullPointerException e) {
			throw new ParseException("Unexpected end of file!");
		} catch (FileNotFoundException e) {
			throw new ParseException("Could not find file " + file.getName()
					+ "!");
		} catch (IOException e) {
			throw new ParseException("Error accessing file to write!");
		}
	}