Trouble with FTP input
I'm writing an FTP client based on a generic socket example I found. I'm not sure if this is a good idea or not. I'm getting a few lines of data from the server, but I was expecting to see the username prompt too.
Here's my code...
public void run()
{
Socket clientSocket = null;
InputStreamReader in = null;
BufferedReader data = null;
PrintWriter out = null;
String temp = "";
setCursor(new Cursor(Cursor.WAIT_CURSOR));
try
{
for(int i = 0; i < 80; i++) cbuff = ' ';
lblResult.setText("Contacting "+txtServer.getText()+" ...");
clientSocket = new Socket(txtServer.getText(), jftp_port);
out = new PrintWriter(clientSocket.getOutputStream());
in = new InputStreamReader(clientSocket.getInputStream());
data = new BufferedReader(in);
data.read(cbuff, 0, 80);
lblResult.setText(String.copyValueOf(cbuff) + '\n');
//clean up
out.close();
in.close();
data.close();
clientSocket.close();
}
catch(UnknownHostException e)
{
lblResult.setText("Unknown host: "+ e.getMessage());
}
catch(IOException ioe)
{
lblResult.setText("IO Error "+ ioe.getMessage());
}
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
The example is from a client we did last semester for a random quote of the day server/client.
Thanks,
Jason

