1

i am new to android and java development and want some help.
this question may sound stupid, but i am trying to make an android application that sends a file (located on an android device) to a java server running on PC(windows) using FTP (android client and java server are connected to the same wireless network). i have gone through so many questions but that cannot satisfy my answer.
i have also gone through some libraries - jftp and simpleftp but i really dont know how to use it. some piece of code might be useful.
consider file on android /sdcard/temp/sample.rar of size 100 mb.
p.s. - file can be on any type. and can be of large size 100 - 150 mb. i am currently using TCP to send messages from android client to java server.

some code....

clientSocket = serverSocket.accept();
DataInputStream dis = new DataInputStream(clientSocket.getInputStream());
String command = dis.readUTF();
String prefix = command.substring(0,3);
String postfix = command.substring(3);

if(prefix.equals("key"))
{
new Thread()
{
public void run()
{
System.out.println("key postfix" + postfix);
int keyCode = Integer.parseInt(postfix); <br/> keyPress(keyCode);
}
}.start();
}

user2291096
  • 13
  • 1
  • 4
  • Similar to your problem .. have a look at this may help you http://stackoverflow.com/questions/1567601/android-ftp-library – Manoj Pal May 01 '13 at 09:35
  • @manoj pal : thanks for the client part. but i also want to setup a FTP java server. any help for that? – user2291096 May 01 '13 at 10:38

1 Answers1

0

The same way you are sending the messages from Android to PC will be used to send a file from android to PC. You will have to use byte arrays to send the messages from android to PC.

For example you can define:

  1. 1st packet will contain the name of the file.
  2. 2nd packet will contain the length of the file.
  3. 3rd packet will contain 1st packet of the file... . .

Similarly you can then send the whole file to your PC Server. I hope this will help

For Java FTP Server:

http://mina.apache.org/ftpserver-project/embedding_ftpserver.html

For Android FTP Client As manoj mentioned earlier in his comments:

Android FTP Library

Community
  • 1
  • 1
user_CC
  • 4,686
  • 3
  • 20
  • 15
  • thanks for the help. that is helpful. but i want to send large files approx 150 mb in size using FTP. but this can also be implemented. can you show me piece of code to send. if yes then it can be very useful... – user2291096 May 01 '13 at 09:50
  • If you show me your code what you have done I will modify it to reflect how it can be done. I haven't got any thing implemented at the moment otherwise I would have shared it with you. Further if you want to use FTP then you will have to implement FTP Server as well have you done that? – user_CC May 01 '13 at 10:10
  • No i was looking forward to create a ftp server as soon as the server recieves "ftp" command. but i dont know how to implement it.. currently i implemented keyboard keyevents.. and this is my code.... see the code in comment.... – user2291096 May 01 '13 at 10:16
  • Ok so you implement the Java FTP Server first and then start writing the client using the client ftp library http://mina.apache.org/ftpserver-project/embedding_ftpserver.html – user_CC May 01 '13 at 11:06
  • Also If you just want to transfer a file then keep it simple and use the method I have mentioned...Implementing FTP Client and server will be more complicated.. – user_CC May 01 '13 at 11:10