Mar*_*-03 4 java xml bufferedreader
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());
}
}
Run Code Online (Sandbox Code Playgroud)
你好.正如您所看到的,我BufferedReader不是在阅读整个在线XML文件,我不知道为什么.知道为什么会这样吗?
谢谢.
The*_*ind 10
while(reader1.readLine()!= null) // reading here
{
System.out.println(reader1.readLine()); // and here
}
Run Code Online (Sandbox Code Playgroud)
每次循环时都在跳过一行...
做,
String line=null;
while((line=reader1.readLine())!= null) // reading here
{
System.out.println(line); // and displaying here
}
Run Code Online (Sandbox Code Playgroud)