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
}

10-02 03:34