Re: BufferedInputReader

1999-12-22 Thread Kero van Gelder


  I encountered a small problem using the BufferedInputStream.
  When telling it to skip a big number of bytes, it stops at the first
  2k boundary (or, more precisely, from position 32 to skip 37919 bytes
  lets it stop at position 2048).
 
 This is not a bug.  The skip() method as defined in FilterInputStream
 is not required to skip the number of bytes requested.
 
 Ref: 
http://java.sun.com/products/jdk/1.2/docs/api/java/io/BufferedInputStream.html#skip(long)

Forgive my ignorance!

I guess there is no use in complaining about such a useless API in
this newsgroup, is there? Sorry, but I could not possibly imagine that
this was _not_ a bug... Not that ``for a variety of reasons'' is a
clear way of telling when skip(n) might not skip n bytes.

(if anybody knows an alternative call that I can use, mail me :-)

I guess I'll ByteArray my files instead of Buffering them. Fast enough
and no problems with 2k boundaries. Lucky for me my files are only
several 100k long.

 No code was stolen :-) Kaffe tries to behave like JDK whenever possible
 and in this case is just using the same default buffer size (eg., 2048).

Fine with me. Sorry if I appeared harsh.
(But it is something to be wary about.)

 Presumably, JDK and kaffe use the same (obvious) skip() algorithm,
 i.e., skip remaining buffered data first.

Apparently...

It's good to test programs on 1 JVM, preferably 1.1 and 1.2
mixed.

Merry Christmas everybody!
Kero.

+--- Kero -- [EMAIL PROTECTED] ---+
| If there were no hell to pay, would you still need a God? |
| -- Leah Androne   |
+--- M38C --- http://www.huizen.dds.nl/~kero ---+



Re: BufferedInputReader

1999-12-21 Thread Archie Cobbs


Kero van Gelder writes:
 I encountered a small problem using the BufferedInputStream.
 When telling it to skip a big number of bytes, it stops at the first
 2k boundary (or, more precisely, from position 32 to skip 37919 bytes
 lets it stop at position 2048).
 
 Removing the BufferedInputStream and using only the
 ByteArrayInputStream that is underneath works.
 
 The funny thing is that sun/blackdown:
 $ java -version
 java version "1.2"
 Classic VM (build Linux_JDK_1.2_pre-release-v2, native threads, sunwjit)
 
 has _exactly_ the same problem, where _exactly_ the same solution worked.
 I don't want to be rude, but who is stealing code from whom?

This is not a bug.  The skip() method as defined in FilterInputStream
is not required to skip the number of bytes requested.

Ref: 
http://java.sun.com/products/jdk/1.2/docs/api/java/io/BufferedInputStream.html#skip(long)

No code was stolen :-) Kaffe tries to behave like JDK whenever possible
and in this case is just using the same default buffer size (eg., 2048).

Presumably, JDK and kaffe use the same (obvious) skip() algorithm,
i.e., skip remaining buffered data first.

-Archie

___
Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com