问题描述
嗨。
我想从facebook通知Feed中读取文本并将其保存在文件中。所以这是我试过的代码。
Hi.
I want to read text from a facebook notification feed and save it in a file. So here is the code I've tried.
URL url = new URL("https://www.facebook.com/feeds/notifications.php?id=100007845703285&viewer=100007845703285&key=AWjriLTeFA0m2TfD&format=rss20");
HttpsURLConnection urlCon = (HttpsURLConnection) url.openConnection();
InputStream stream = urlCon.getInputStream();
byte[] streamBytes = new byte[stream.available()];
stream.read(streamBytes);
stream.close();
FileOutputStream writer = new FileOutputStream("feed.txt");
writer.write(streamBytes);
但问题是这不会从该Feed中检索所有文本。 。
我试图使用URLConnection和HttpURLConnection而不是HttpsURLConnection。但它也没有用。输出不包含至少一半的Feed。
我的代码有什么问题?是否有任何其他类读取网页的整个内容而不是URL或URLConnection?
提前致谢!
But the problem is this doesn't retrieve all the text from that feed..
I've tried to use both URLConnection, and HttpURLConnection instead of HttpsURLConnection. But it didn't work either. The output doesn't contain at least half of the feed.
What's the wrong with my code ? and is there any other class that reads the whole content of a web page instead of a URL or URLConnection ?
Thanks in advance !
推荐答案
这篇关于Java URLConnection不读取所有文本。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!