Showing posts with label How to access FTP server in android. Show all posts
Showing posts with label How to access FTP server in android. Show all posts

Wednesday, May 1, 2013

[android help] How to access FTP server in android

How to access FTP server in android - Stack Overflow








Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















I am working on a project where I need to access FTP server using its domain, username and password. I want to save data and retrieve data from there.


Please suggest any solution for this.


























Look for commons net apache library - http://commons.apache.org/proper/commons-net/. It provides a tools for work with FTP.


Code example for download video file.



FileOutputStream videoOut;
File targetFile = new File("path");

FTPClient ftpClient = new FTPClient();
try {
ftpClient.connect("your.ftp.address", 21);
ftpClient.enterLocalPassiveMode();
ftpClient.login("login", "password");

ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);// Used for video
targetFile.createNewFile();
videoOut = new FileOutputStream(targetFile);
boolean result=ftpClient.retrieveFile("/" + "filename-to-download", videoOut);

ftpClient.disconnect();
videoOut.close();

} catch (IOException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}


I don't work with file upload but I think there are a lot of examples in web.























To Upload file, I used this code in one project. I got code from this link : AndroidDemo


Also, this guys is using it in secured way.


I hope this can help you out.

















Not the answer you're looking for? Browse other questions tagged or ask your own question.







default







.

stackoverflow.comm

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...