[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
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 :blush:
So all i had to do was change the code to ("img_" + (counter+1) + ".bmp")
:blush: