Advertisement: RazorSQL
Query, update, navigate, and manage all databases from one database
client with ease using RazorSQL, a database query tool, SQL Editor,
database navigator, and administraton tool.
Download a free trial today!
Advertisement: EditRocket
The text editor for programmers with coding tools and support for over 20 languages. Download a free trial today!
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.net.Socket;
public class FTPLogin
{
public static void main (String args[])
{
Socket socket = null;
BufferedReader in = null;
PrintWriter out = null;
String line = null;
if (args.length != 3)
{
System.out.println ("USAGE: IP USER PASS");
}
else
{
try
{
socket = new Socket (args[0], 21);
in = new BufferedReader (new InputStreamReader(socket.getInputStream()));
out = new PrintWriter (socket.getOutputStream());
out.println("user "+ args[1]);
out.println("pass "+ args[2]);
out.println("pwd");
out.println ("quit");
out.flush();
while ( (line = in.readLine()) != null)
{
System.out.println(line);
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
finally
{
try
{
out.close();
in.close();
socket.close();
}
catch (Exception fe)
{
System.out.println ("RESOURCE CLOSE EXCEPTION " +fe.getMessage());
}
}
} //end else
} //end main
} //end class