I have a dubt about to class BufferedReader. This my test. I create the simple txt file: "test.txt" with 1024 lines. Each line contains the line number and the file name (example: "1 - test.txt"):
Test file creation:
$ for i in {0..1023}; do echo "$i - test.txt" >> test.txt; done
$ ls -la test.txt
-rw-r--r-- 1 osb osb 12288 Oct 26 12:01 test.txt
The Java class for my test (f is a variable of File class):
...
while (f.exists())
{
BufferedReader br = null;
try
{
br = new BufferedReader( new FileReader( f ), 10);
while ((line = br.readLine())!=null)
{
System.out.println (line);
Thread.sleep(1000);
}
}
...
catch excepion
...
finally
{
try
{
br.close();
}
catch (IOException e)
{
System.out.println ("\nError closing Buffer reader!");
e.printStackTrace();
}
br = null;
line = null;
}
}
...
When the application starts to write the lines I execute this unix command:
gzip test.txt
I expect an exception because the buffer size is very little ( 10 byte ) less than un line size, but the application reads all the 1024 lines and only when it reaches the end of the file it raises the exception ( file not exist! ). Does the BufferedReader has a buffersize greater than 10? Is there a minimum buffer size?
Thanks