Re: DataInputStream
On Oct 5, 11:52 pm, Lew <lewbl...@gmail.com> wrote:
Robert Klemme wrote:
bob wrote:
The issue is that it's too slow.
How slow is that, and how fast should it be?
How much faster could it be, and what makes you think that's possible?
Ah, now we're getting closer to the point. I'd first test whether th=
e
slowness is caused by the underlying stream or the reading procedure.
If it's the stream (e.g. because you read unbuffered from a socket)
then you might want to add buffering or you need a faster NIC. If
it's in the reading then look at Mark's suggestion.
The OS could also be a factor. So could other loads on the system, par=
ticularly the I/O subsystem. Given that we don't know what speed is "too=
slow" and what speed is acceptable, nor the system configuration, nor the =
load profile, nor anything else, there's nothing we can say to affect the "=
too slow" evaluation.
Absolutely. I just wanted to partition the problem space in "float
reading and parsing" and "general IO" because that information is
needed to decide whether the approach to reading floats is wrong
because it's too slow. OS then falls into "general IO".
What I'm hoping for is something like this:
byte[] b = new byte[=
numfloats*4];
Did you indent enough there?
ts*4);
) b;
return f;
I don't know why, but it won't let me do the cast. Any ideas?
See Patricia's reply. Java works fundamentally different from C or C=
+
+. For example, there are no pointers into memory. I seriously
Well, there are, actually.
I can see why you say that (because eventually every reference of any
kind points to a place in memory). But for the sake of this
discussion and the general concept of Java I'd rather stick with "no
pointers into memory in Java" because that makes it crystal clear that
there is not that free access to memory cells as in C/C++. Actually
objects can even move in memory so an unchanged reference can point to
different locations throughout its lifetime, while an unchanged C
pointer always references the same memory addresses.
In the case of the OP's code, they're 'b' and 'f'. However, the poi=
nters in Java are rigidly typed, unlike those in C, so you cannot cast a po=
inter to 'byte[]' into a pointer to 'float[]'.
That's why I prefer the term "object reference" which is also what the
JLS uses (even though there are some occurrences of "pointer" and we
have "NullPointerException").
Kind regards
robert