0

I’m creating an application for Android and would like it to be able to read a text file via anonymous FTP.

I've tried URLConnection, but it doesn't seem to be working. After some Google searching it appears that URLConnection doesn't always work with some FTP servers.

All Java FTP connection libraries I've found require you to download the file to a local location before reading it.

However, I would like to have the same functionality as URLConnection in that I can just use the following similar code:

String urlString = "ftp://ftp.domain.com/testing.txt";
URL url = new URL(urlString);
FTPConnection conn = url.openConnection();

BufferedReader reader = new BufferedReader(new InputStreamReader(
                conn.getInputStream()));
tchrist
  • 76,727
  • 28
  • 123
  • 176
postalservice14
  • 2,435
  • 4
  • 24
  • 33
  • Does your ftp connection require a password? – Ritwik Bose Jan 10 '10 at 10:00
  • Can you give more details than "doesn't seem to be working"? – Jon Skeet Jan 10 '10 at 10:08
  • URLConnection should work with what you have. Please describe why it fails. – Thorbjørn Ravn Andersen Jan 10 '10 at 11:32
  • It says connection failed when I use URLConnection. No it doesn't require a password. – postalservice14 Jan 11 '10 at 18:01
  • This comprehensive article compares available Java FTP libraries, explains the two RFCs and their implementations in the SUN JDK and has a lot of more links: [Java FTP client libraries reviewed](http://www.javaworld.com/javaworld/jw-04-2003/jw-0404-ftp.html?page=1) And there was a recommendation for [Zehon](http://zehon.com/index.html), that seems to be able to download a file to an input stream. Hope it works with android as well. – Andreas Dolk Jan 10 '10 at 11:34

0 Answers0