I am building an app which sends/recv large data to/from my remote FTP server. I want to implement FTP commands over SocketConnection. I have to first open the connection and then user and then password to server, after verifying the required response I want to begin download/upload. I dn know how to begin. I have only idea :
public class SimpleFTP
{
private static boolean DEBUG = false;
StreamConnectionNotifier connectionNofitier = null;
InputStreamReader reader = null;
OutputStreamWriter writer = null;
StreamConnection conn = null;
private static String URL = null;
private String server = "XXX.XXX.XXX.XX";
private String port = "21";
private String user = "user";
private String pwd = "pwd";
public SimpleFTP()
{
}
public void connect() throws IOException
{
try
{
URL = "socket://" + server + port + user + pwd+";deviceside=true";
URL = "socket://" + server + port +";deviceside=true";
connectionNofitier = (StreamConnectionNotifier) Connector.open(URL);
System.out.println(Connector.open(URL));
if(connectionNofitier!=null)
System.out.println("StreamConnectionNotifier is already connected..!!");
conn = (StreamConnection)connectionNofitier.acceptAndOpen(); ;
if(conn!=null) //my Simulator hangs here and does nothing....
System.out.println("StreamConnection is already connected..!!");
reader = new InputStreamReader( conn.openInputStream() );
writer = new OutputStreamWriter( conn.openOutputStream() ) ;
}
catch(Exception e )
{
System.out.println("Exception in Connect : "+e.toString() );
}
}
}
I need suggestions/advice from experts to how to perform this.