import java.awt.*;
    import java.awt.image.BufferedImage;

    import javax.imageio.ImageIO;
    import javax.swing.*;


    public class one extends JFrame {

        public one()
            JPanel p = new JPanel();
            JLabel l = new JLabel();
            setSize(600, 400);
            setLayout(new BorderLayout());
            BufferedImage image;
                File file = new File("D://Photos//foto(222).jpg");
                image =;
                l.setIcon(new ImageIcon(image));
            catch( Exception e)
                l.setText("Cannot read image");

        public static void main(String[] args) 
            new one();

This is my code..
when i run this code error appear..
javax.imageio.IIOException: Can't read input file!
    at Source)
    at one.<init>(
    at one.main(
Can't read input file!

    Please give solution...

Recommended Answers

All 7 Replies

Make sure the path to the file is correct.

Rather than just printing the exception's messgae, do a full e.printStackTrace();
This will give you the details of any errors that caused the exception eg file not found, incorrect priveleges to read file etc etc

Where did the posted error message come from? The code must have had a call to printStackTrace() to create it. The posted code would not generate that message.

I think problem in class.
i am use jdk1.6.0_33. in windows xp
this same problem comes in J2ME programing.
IO class is not load the files.
but using JFileChooser can load the Files.

I need any extra jar for IO or what i'm do for this problem?? .

The posted code works for me when I change the path to an image file on my PC.

ya thanx sir...
i find my mistake.
sorry for wrong.
my mistake is in path name.
it's now working..

i have another doubt.
for example integer array no of numbers..
as the same File array can store no of files inside the array.
it's possible or not..?
if possible please give the code..
i like File array Binding is runtime.

Sorry, I do not understand your question about arrays and files.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.