• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Reading Images

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Here. Have a potato. I grew it in my armpit. And from my other armpit, this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic