Results 1 to 2 of 2

Thread: [RESOLVED] importing multiple image files

  1. #1

    Thread Starter
    Hyperactive Member Greyskull's Avatar
    Join Date
    Dec 2003
    Location
    somewhere in England
    Posts
    382

    Resolved [RESOLVED] importing multiple image files

    Rather than using 52 swith statements, is it possible to use a loop that can import images?

    Atm my code is something like:


    Code:
    //by K0502201
    public void getImg(int counter)
        {
            //inFile = new File(counter + ".bmp")
            inFile = new File("img_" + counter + ".bmp");
            
            try { img = ImageIO.read(inFile); }
            
            catch (IOException e)
            { System.out.println("Image error: " + e); }
        }
    that class is called inside a for loop. However, i dnt think im doing this statement correctly as i get a null pointer exception

    Any help is greatly aprreciated
    Please go to the Thread Tools menu and click Mark Thread Resolved when your post is answered
    If someone helped you today then please consider rating their post.

  2. #2

    Thread Starter
    Hyperactive Member Greyskull's Avatar
    Join Date
    Dec 2003
    Location
    somewhere in England
    Posts
    382

    Re: importing multiple image files

    finally found the cause why it isnt working. The code was right, it was just pointing to an empty file

    So all i had to do was change the code to ("img_" + (counter+1) + ".bmp")

    Please go to the Thread Tools menu and click Mark Thread Resolved when your post is answered
    If someone helped you today then please consider rating their post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width