I want to use equivalent of Expect in Java. This is a simple code:
public class TelnetJExpect
{
    @Test
    public void telnetTest() 
    {
        ExpectJ expectinator = new ExpectJ(5);
        try
        {
            Spawn shell = expectinator.spawn("172.17.80.161", 23);
            System.out.println("\nExit: " + shell.getCurrentStandardOutContents());
            shell.stop();
        }
        catch (Exception e)
        {
            e.printStackTrace();
            assertTrue(false);
        }
    }
}
As a result, I'm getting garbage:
ÿýÿý ÿý#ÿý'
Exit:
ÿýÿý ÿý#ÿý'
However, I get connection when I use telnet from the command line.
Please help.
                        
try this