Results 1 to 3 of 3
Thread: problem with reading image
- 04-17-2012, 01:23 PM #1
Member
- Join Date
- Apr 2012
- Posts
- 3
- Rep Power
- 0
problem with reading image
hey guys,
i have a problem reading an image file to my program.
Java Code:public class IOClass { private File file; private BufferedImage image; public BufferedImage inputImage(){ try { file = new File("leaf.jpg"); image = ImageIO.read(file); } catch (IOException e) { } return image; } public static void main(String[] args){ IOClass io = new IOClass(); BufferedImage i = io.inputImage(); if(i== null){ System.out.println(" image fail!!!"); } } }
does anyone have any idea what is wrong with my code? i've been scratching my head for over two hours trying to figure out
what is the problem.
the leaf.jpg file is in the src folder if this info helps, and im using eclipse.
URGENT HELP!!
any ideas will be gratefully appreciated. thx.
regards,
josh.
- 04-17-2012, 01:30 PM #2
Re: problem with reading image
Are you sure the file is in the folder where the program is trying to read it?
Print out the absolute path for the file object to see where the program is looking for the file.If you don't understand my response, don't ignore it, ask a question.
- 04-17-2012, 05:33 PM #3
Member
- Join Date
- Apr 2012
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Reading MS doc image from Java
By gopal026 in forum New To JavaReplies: 1Last Post: 12-06-2011, 01:06 PM -
Help : reading image and draw it on GUI
By Rodrigo91 in forum Java 2DReplies: 0Last Post: 03-26-2011, 10:01 PM -
problem with reading excel sheet data reading using poi libraries
By sandeepsai17 in forum New To JavaReplies: 5Last Post: 08-21-2009, 11:03 AM -
Image reading from URL problem
By paras in forum Advanced JavaReplies: 4Last Post: 04-18-2009, 07:26 AM -
[SOLVED] Image reading from URL problem
By paras in forum New To JavaReplies: 3Last Post: 04-18-2009, 05:11 AM
Bookmarks