Lexer.java with IO implementation for java