我尝试从网页上阅读整个源代码,但我只收到了一半或更少。 我的代码有问题吗?
这是我写的代码:
public class ReadFromReuters {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
ReadFromReuters rfr = new ReadFromReuters();
try(BufferedReader br = new BufferedReader(new InputStreamReader(rfr.getConnection().getInputStream()))){
String str;
while((str = br.readLine()) != null){
System.out.println(str);
}
}catch(IOException ioe){}
}
public URLConnection getConnection() throws MalformedURLException, IOException{
URL reuters = new URL("http://www.quickflix.com.au/browse/play");
URLConnection conn = reuters.openConnection();
return conn;
}
public void splitBy(String str){
}
}
最佳答案
测试了你的代码。似乎工作。我已经将您的代码输出和站点的源代码与 WinMerge 进行了比较。结果:没有差异。 注意:本站使用分页!您只能获得包含此代码的第一页。
关于Java 只读了一半的 web url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19524929/