Yea, exactly. I used the two methods because I wanted to have examples
of what would and wouldn't work, and the second one is actually from a
DejaNews search, from a thread on the fastest way to read a file. I
figured this method may have been why the problem was reported in the
first place. It should be pointed out that if you change the line
long llen = f.length();
to
long llen = 20L;
then the code will read the first 20 (or so) chars of a file, including
the ones in /proc. readFully() may not be the best method to call in
this example, but again it was just to show what is going on. Cat, more
and less were all able to read the files fine as well, but there is the
following line sitting in /var/log/messages:
Feb 3 15:43:28 asylum kernel: less uses obsolete /proc/pci interface
BTW, I less'd that entry a few times, and it only shows once. I have no
idea what that is trying to say, but it does.
FWIW, I'm on a Red Hat 5.1 system, with all updates, running 2.2.1
kernel.
As an aside that is not worth a seperate message, great job on getting
the JCK test to run guys! Hope all the bugs are easily squishable.
Aaron Gaudio wrote:
>
> Quite simple: in the second method he creates an array of zero length
> because he sets llen to f.length(). Well as we already discussed, the
> file will appear to have zero length, which means llen == 0 and
> when he initializes b, he uses new byte[len]...a zero-length array. Therefore
> it makes perfect sense that nothing would be read into the array, since
> readFully() will only read as many bytes into the array as can fit.
>
> The disparity between the two methods is that method 1 does not use the length
> of the file at all. It simply reads lines until there's no more lines to
> read (in other words, the last line read is null). That's basically what
> my example does, only I didn't much with BufferedReader, I simply did it
> char by char (less efficient perhaps, but its a proof of concept). The
> second method tries to "predict" how many bytes there are, by checking the
> file size, which we know will be zero.
>
> And lo, the chronicles report that Dimitris Vyzovitis spake thusly unto the masses:
> >
> > Aaron Gaudio wrote:
> >
> > > Where did you get this idea? FileReader and FileInputStream both work
> > > the same.
> >
> > Try this (Sean Kellner's code -> [EMAIL PROTECTED])
> >
> > [Code snipped -Ed.]
> >
> >
> > I also used to think that the Reader and the Stream work the same way, but it
>seems they don't.
> > Any clues (please don't quote "Java in a Nutshell", I also have the book) ?
>
> Why not? It may at times be vague or lacking, but what information it does
> provide is unerringly correct.
>
> --
>
> ¤--------------------------------------------------------------------¤
> | Aaron Gaudio mailto:[EMAIL PROTECTED] |
> | http://www.rit.edu/~adg1653/ |
> ¤--------------------------------------------------------------------¤
> | "The fool finds ignorance all around him. |
> | The wise man finds ignorance within." |
> ¤--------------------------------------------------------------------¤
>
> Use of any of my email addresses is subject to the terms found at
> http://www.rit.edu/~adg1653/email.shtml. By using any of my addresses, you
> agree to be bound by the terms therein.
--
Sean Kellner
[EMAIL PROTECTED]