• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading Images

 
Scott Branchini
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to read in am image from a file. I am using the following code:

Image image = null;
try {
// first attempt
image = ImageIO.read(new File("image.jpg"));

// second attempt
InputStream is = new BufferedInputStream(
new FileInputStream("image.jpg"));

image = ImageIO.read(is);
} catch (IOException e) {
}

I have the two different ways that I am trying to read in the image and both do not work. I eventaully want to stick the image in the database, but that is another story. Thank you in advance.
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do these calls "not work"?
The following is very bad programming practice:

If an exception were thrown you'd never know it. At the very least, print out a message that an unexpected exception occurred. I'd suggest invoking e.printStackTrace() as well.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!