aspose file tools*
The moose likes General Computing and the fly likes imageio.read Bytearrayinputstream null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "imageio.read Bytearrayinputstream null" Watch "imageio.read Bytearrayinputstream null" New topic
Author

imageio.read Bytearrayinputstream null

ramesh poorella
Ranch Hand

Joined: Jul 19, 2011
Posts: 59
Hi ,
The bellow is my code, here i got the null at bimg = ImageIO.read(bin);


java.io.InputStream in = new FileInputStream("D:\\123.tif");
int size=in.available();
byte[] buff = new byte[8000];

int bytesRead = 0;
ByteArrayOutputStream bao = new ByteArrayOutputStream();
buff = new byte[in.available()];
while((bytesRead = in.read(buff)) != -1) {
bao.write(buff, 0, bytesRead);
}

byte[] data = bao.toByteArray();


BufferedImage bimg;
java.io.InputStream bin = new ByteArrayInputStream(data);
try {
bimg= ImageIO.read(bin);
} catch (IOException ioe) {
throw new RuntimeException(
"Failed to render image",
ioe);
}




please help me why i am getting null value
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Is "bin" null?


Ping & DNS - updated with new look and Ping home screen widget
ramesh poorella
Ranch Hand

Joined: Jul 19, 2011
Posts: 59


bin is not getting null.

bimg is getting null
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Not sure what "getting null" means - *is* it null?
ramesh poorella
Ranch Hand

Joined: Jul 19, 2011
Posts: 59

bimg is null
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3946
    
  17

According to the api for javax.imageio.ImageIO the read() method would return null if there is no registered reader that can decode the image file. So you need to find a reader which will read that type of file and make sure it gets loaded.


Steve
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
I'll ask again:
Ulf Dittmer wrote:Is "bin" null?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: imageio.read Bytearrayinputstream null
 
Similar Threads
Upload and Resize Advice
streaming an HTML document
facing problem in writing Excel Doc bytes into ServletOutputStream
Convert image to byte[] and viceversa
how to convert a Bytearray input stream to String