> I think I've tracked the problem down to the finally statement. I
> think it is closing the stream too early. I will move it into the
> catch tonight and see how that goes.

Signature
Knute Johnson
email s/nospam/knute/
On Nov 15, 11:56 am, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
wrote:
> > This class is just for reading the data from the file. The file may
> > be large, and I am attempting to read it in chunks so the user doesn't
[quoted text clipped - 5 lines]
> conversion from bytes to Vectors and back is going to be very expensive.
> Why don't you just read the file, buffer it if you want?
How do I buffer it without putting it into something?
> >> Why does getData() only return the first element? You could
> >> possibly read more than one but never retrieve it.
[quoted text clipped - 7 lines]
>
> Vector.get() does not remove that element from the Vector.
I'm sorry, I came across that bug and fixed it, I didn't notice it was
included in the above code. I now have a data.remove(0) in there too.
> You need to read your data and process it. Storing byte data in Vectors
> doesn't make a lot of sense. If you don't want to hold up your GUI
> while you read the data, you need to read it in another thread.
Notice that this class extends thread.
The general principle is that the user clicks File>Open and selects a
file from the dialog. The GUI checks to make sure the file exists,
and attempts to open a stream from it. If all has gone well, the GUI
creates an instance of this loader thread, passes in the stream,
registers itself as a listener, and starts the thread. This class
then reads the data from the file in 16 byte increments, stores each
increment in the data vector, and notifies the GUI that there is data
waiting. The GUI can then come at its own leisure and grab the first
element off of the data vector and put it on the screen after some
processing.
Knute Johnson - 16 Nov 2007 18:12 GMT
> On Nov 15, 11:56 am, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
> wrote:
[quoted text clipped - 8 lines]
>
> How do I buffer it without putting it into something?
It would make the most sense to process your data as it is read.
>>>> Why does getData() only return the first element? You could
>>>> possibly read more than one but never retrieve it.
[quoted text clipped - 8 lines]
> I'm sorry, I came across that bug and fixed it, I didn't notice it was
> included in the above code. I now have a data.remove(0) in there too.
You don't need both, only the remove(). I returns the element too.
>> You need to read your data and process it. Storing byte data in Vectors
>> doesn't make a lot of sense. If you don't want to hold up your GUI
[quoted text clipped - 12 lines]
> element off of the data vector and put it on the screen after some
> processing.
If this is some exercise in how to make it more complicated than have
fun. Otherwise, read the data, process it if you need to, and display
it. I couldn't have come up with a more inefficient or complicated way
to do this if I had thought about it.
What sort of data is it actually? Why can you not just read the file
and display the data? How much data is there?

Signature
Knute Johnson
email s/nospam/knute/