|
-
Feb 18th, 2008, 07:06 AM
#1
Thread Starter
Hyperactive Member
[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.
-
Feb 18th, 2008, 12:07 PM
#2
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|