简体   繁体   English

从txt文件中读取数据而不下载它?

[英]Read data from a txt file without downloading it?

I want to parse information out of the text file this serves up: 我想解析出来的文本文件中的信息:

http://finance.yahoo.com/d/quotes.txt?s=GOOG+YHOO&f=sak2 http://finance.yahoo.com/d/quotes.txt?s=GOOG+YHOO&f=sak2

Is there a way to do it within an app without downloading the file first? 有没有办法在应用程序中执行它而不先下载文件? Somehow stream the text content? 以某种方式流式传输文本内容?

Open a Http connection to the URL (using either the builtin HttpURLConnection or use a library like commons-httpclient), and read the results from the input stream as the contents are transferred. 打开与URL的Http连接(使用内置的HttpURLConnection或使用类似commons-httpclient的库),并在传输内容时从输入流中读取结果。

It is impossible to read the file without transferring the contents of the file over the network. 如果不通过网络传输文件内容,则无法读取文件。 However, you don't need to transfer the contents and store the file on disk - you can simply read the file from the stream and not persist it to disk. 但是,您不需要传输内容并将文件存储在磁盘上 - 您只需从流中读取文件,而不是将其保留在磁盘上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM