You might consider using the
Apache Commons Net package. It lists Telnet in the supported protocol.
This examples guide can help you start.
Note that while executing
telnet you fork a sub-process from the cmd.exe. Try giving the
dir command in your code and check if it works first with the cmd.