从 URL 检索 txt 文件的内容到 Android
我希望能够从互联网检索 .txt 文件的内容,并将其加载到 EditText 中。我尝试使用此页面上的代码:在Android上从服务器读取文本文件
正如您可能已经猜到的那样,它不起作用。我在许多网站上阅读过有关此类问题的信息,但我无法解决任何问题。有人建议 AndroidHttpClient 但我根本找不到任何示例有了这个。
由于我是 Android 编程的新手,如果有人能给我一个小例子,我会很高兴。
I would like to be able to retrieve contents of a .txt file from the internet, and load it in an EditText. I tried using the code on this page: Reading Text File From Server on Android
It didn't work, as you might have guessed. I've read on numerous sites about this type of problem, but I can't get anything to work. Someone suggested AndroidHttpClient but I simply can't find any examples with this.
As I'm a newbie in Android programming, I would love if someone could please give me a small example.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与其说这是一个 Android 问题,不如说这是一个 Java 问题。有几种方法可以做到这一点,但最简单的可能是使用 java.net.HttpURLConnection。
This isn't so much of an Android question as it is a Java question. There are a few ways you could go about doing this, but the simplest might be using
java.net.HttpURLConnection
.