java – BufferedReader没有读取整个在线XML文件

public static void main(String[] args) throws MalformedURLException, IOException 
{
    // TODO code application logic here
    URL link1 = new URL("xmlFileHere");
    InputStream xml = link1.openStream();
    InputStreamReader reader = new InputStreamReader(xml);
    BufferedReader reader1 = new BufferedReader(reader);
    while(reader1.readLine()!= null)
    {
        System.out.println(reader1.readLine());
    }

}

你好.正如您所看到的,我的BufferedReader没有读取整个在线XML文件,我不知道为什么.知道为什么会这样吗?
谢谢.

最佳答案
while(reader1.readLine()!= null)   // reading here
{
System.out.println(reader1.readLine());  // and here
}

每次循环时都在跳过一行…

做,

String line=null;
while((line=reader1.readLine())!= null)   // reading here
{
System.out.println(line);  // and displaying here
}

转载注明原文:java – BufferedReader没有读取整个在线XML文件 - 代码日志