I wonder now, what is the difference between the two methods:
DataInputStream.skipBytes
and DataInputStream.skip
.
I am aware of the fact that skip
must come from InputStream
and skipBytes
from DataInput
, but still, is there any difference. You know, when using streams in J2ME, things get pretty tricky so I need to know!
Would the Input/DataInput Streams returned from the FileConnection
in JSR-75 be any different in handling than any other such streams?
Thanks!
from DataInputStream
:
public final int skipBytes(int n) throws IOException {
int total = 0;
int cur = 0;
while ((total<n) && ((cur = (int) in.skip(n-total)) > 0)) {
total += cur;
}
return total;
}
as you can see from the code, skipBytes
uses skip (InputStream.skip)
the only thing that i can say is that if data in your wrapped inputStream (InputStream inside DataInputStream)changes by another thread, then the result of skipBytes and skip may be different. but if your application just working with single thread then skipBytes and skip are the same.