安卓:Web服务器的文件列表 [英] Android: File listing of web server
问题描述
我想通过Android手机来检索文件从我的(阿帕奇)HTTP服务器列表。搜索网站和论坛都没有成功。我不过能够使用标准的java做到这一点:
I am trying to retrieve file listing from my (apache) http server via an android phone. Searched the web and forum without success. I was however able to do this in standard java using:
package at.klp.serverlist;
import java.net.URL;
import java.util.List;
import org.apache.ivy.util.url.ApacheURLLister;
public class ServerFileListJava {
public static void main(String[] args) {
URL url1;
List serverDir;
try {
url1 = new URL("http://...url to server...");
ApacheURLLister lister1 = new ApacheURLLister();
serverDir = lister1.listAll(url1);
System.out.println(serverDir);
}
catch (Exception e) {
e.printStackTrace();
}
}//end main
}//end class
时的相似课程的Android可用,或者可以将文件通过org.apache.http上市莫名其妙地做*? 我真的不希望使用的WebView,或使用单独的HTML code HTTPGET和Htt的presponse。
Is a similar class available in Android, or can file listing somehow be done using org.apache.http*? I do not really want to use a WebView, or separate the html code using HttpGet and HttpResponse.
感谢了很多帮助,任何想法?
Thanks a lot for helping, any ideas?
解决感谢你的答案。我进口常春藤-2.0.0-rc1.jar到我的项目,不知道这工作!本视频演示如何导入.jar`s到Android项目:的http:// www.youtube.com/watch?v=eY_uqi_qIz0&noredirect=1 谢谢!
Solved thanks to your answers. I imported ivy-2.0.0-rc1.jar into my project, did not know that this works! This video demonstrates how to import .jar`s into an Android project: http://www.youtube.com/watch?v=eY_uqi_qIz0&noredirect=1 thanks!
推荐答案
ApacheURLLister
是pretty的简单类,没有特别的相关性。你应该没有问题,复制它,并直接在code使用它:<一href="https://svn.apache.org/repos/asf/ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/ApacheURLLister.java" rel="nofollow">https://svn.apache.org/repos/asf/ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/ApacheURLLister.java
ApacheURLLister
is a pretty simple class with no special dependencies. You should have no problems copying it and use it directly in your code: https://svn.apache.org/repos/asf/ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/ApacheURLLister.java
这篇关于安卓:Web服务器的文件列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!