如何阅读通过FTP文本文件?文本文件、FTP

2023-09-06 07:27:22 作者:自认与酒同醉

我创建为Android应用程序,并希望它能够通过匿名FTP读取文本文件。

我试过的URLConnection,但它似乎并不奏效。后一些谷歌搜索看来的URLConnection并不总是与某些FTP服务器工作。

我发现所有的Java FTP连接库要求你读它之前,将文件下载到本地位置。

不过,我想在我可以只使用以下类似code相同的功能的URLConnection:

 字符串urlString =ftp://ftp.domain.com/testing.txt;
网址URL =新的URL(urlString);
FTPConnection康恩= url.openConnection();

的BufferedReader读卡器=新的BufferedReader(新的InputStreamReader(
                conn.getInputStream()));
 

解决方案

这COM prehensive文章比较可用的Java FTP库,说明这两个RFC和他们在Sun的JDK实现,并有很多更多的链接:

如何使用FTP软件上传文档

的Java FTP客户端库回顾

和与会者 Zehon 的建议,这似乎是能够将文件下载到一个输入流。希望它与Android工程,以及。

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()));

解决方案

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

And there was a recommendation for Zehon, that seems to be able to download a file to an input stream. Hope it works with android as well.