开发者

Read data from a txt file without downloading it?

开发者 https://www.devze.com 2023-01-22 16:22 出处:网络
I want to parse information out of the text 开发者_如何学JAVAfile this serves up: http://finance.yahoo.com/d/quotes.txt?s=GOOG+YHOO&f=sak2

I want to parse information out of the text 开发者_如何学JAVAfile this serves up:

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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号