Can you help me to load or read multiple images from a file. Because I know read them but How to read single file from a file but how to read multiple images. And I do not know how I would download them all from a specific folder.
For example:
// Atributes
protected BufferedImage imag1;
protected BufferedImage imag2;
protected BufferedImage imag3;
protected BufferedImage imag4;
//Konstructor
public GeneralTurtle(JFrame myForm)
{
poc =0;
this.myForm=myForm;
color= Color.BLACK;
try //loading images from file turtles
{
imag1 = ImageIO.read(new File("hore.png"));
imag2 = ImageIO.read(new File("dole.png"));
imag3 = ImageIO.read(new File("vlavo.png"));
imag4 = ImageIO.read(new File("vpravo.png"));
But I do not know how I would solve it better when I have more pictures. Because this would be laborious and inefficient.
It is written in NetBeans
So you say you have a folder….
You can do this:
For the images you can use some Collection to load them in.
I take the assumption that you can work out the loadImage(File file) method.
And if you have other files then images in that folder you better read up on FileFilter.