> The following code does not work ("file" and "image" are members of the
> class; nextNumber(InputStream) returns the next number in the
[quoted text clipped - 22 lines]
>
> Ron
From the docs:
"ImageIO.read(InputStream is)
Returns:
a BufferedImage containing the decoded contents of the input, or null."

Signature
Knute Johnson
email s/nospam/knute/
> The following code does not work ("file" and "image" are members of the
> class; nextNumber(InputStream) returns the next number in the
[quoted text clipped - 9 lines]
> in.close();
> }
what do you want with PrintStream?
note also that available gives you only how much bytes may be read without
blocking, NOT full size of data behind stream.
> public void read(InputStream stream) throws IOException {
> int size = (int)nextNumber(stream);
[quoted text clipped - 3 lines]
> image = ImageIO.read(imageStream);
> }
similar problem here: InputStream.read(buf, 0, size) returns how much byte
were read.
Use BufferedInputStream.readFully().
BTW why don't you create image direct from supplied stream?
public void read(InputStream stream) throws IOException {
image = ImageIO.read(stream);
}
Andrey

Signature
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities
Ron - 23 Jun 2006 12:32 GMT
> note also that available gives you only how much bytes may be read without
> blocking, NOT full size of data behind stream.
I'm sure that it's giving me the full size of the file. It returns 1283
and the size of the file is 1283.
> BTW why don't you create image direct from supplied stream?
Because the stream has more data than that of the image. I'm developing
a graphics program that has the ability to import images. I want the
files that my program to generate to imbed these images within the
file. So, the files look like this:
File header
Object 1 data...
Object 2 data...
Imbedded image header
[imbedded image data]
Object 3 data...
...
Ron - 23 Jun 2006 13:12 GMT
Nevermind... the problem was that I wasn't reading in the newline
character created after stream.println(size) before I did in.read(b).
It works perfectly now. Thanks for the help anyway.
> > The following code does not work ("file" and "image" are members of the
> > class; nextNumber(InputStream) returns the next number in the
[quoted text clipped - 38 lines]
> http://reader.imagero.com Java image reader
> http://jgui.imagero.com Java GUI components and utilities