Re: BufferedReader.readLine() hangs
From: David B. Held (dave.held_at_arrayservicesgrp.com)
Date: 02/01/05
- Next message: Irlan agous: "UML to Java"
- Previous message: David B. Held: "Re: BufferedReader.readLine() hangs"
- In reply to: Gordon Beaton: "Re: BufferedReader.readLine() hangs"
- Next in thread: Gordon Beaton: "Re: BufferedReader.readLine() hangs"
- Reply: Gordon Beaton: "Re: BufferedReader.readLine() hangs"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 1 Feb 2005 06:50:15 -0800
Others have answered my question, but they haven't solved the problem.
I was suspicious about BufferedReader.ready(), but I don't have much
experience with Java, and I inherited the code that originally called
it. I changed my test code to eliminate calls to ready(), but it still
hangs. Here is the revised version:
import java.io.BufferedReader;
import java.io.FileReader;
public class ReadTest
{
public static void main(String[] args)
{
try
{
BufferedReader in = new BufferedReader(new
FileReader(args[0]));
while (ReadTest.getRow(in));
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static boolean getRow(BufferedReader in) throws Exception
{
for (int i = 0; i != 10; ++i)
{
String s = in.readLine();
if (s == null) return false;
System.out.println(s);
}
return true;
}
}
I'm testing it on a 3.8 MB file, but any suitably large file will do.
Obviously, the contents shouldn't matter, but just in case someone
thinks it does, I just captured the output of ps and appended the file
to itself many times. I would appreciate it if someone else tried it
on their server to see if they can reproduce the issue. Like I said,
it only occurs with the server VM, so far as I can tell.
Dave
- Next message: Irlan agous: "UML to Java"
- Previous message: David B. Held: "Re: BufferedReader.readLine() hangs"
- In reply to: Gordon Beaton: "Re: BufferedReader.readLine() hangs"
- Next in thread: Gordon Beaton: "Re: BufferedReader.readLine() hangs"
- Reply: Gordon Beaton: "Re: BufferedReader.readLine() hangs"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|