/* @(#)ImageTools.java 1.0 12 October 2004 */ import java.awt.*; import javax.swing.*; import java.io.*; /** *
Class ImageTools is a special purpose class for
* reading images from a directory.
The method that reads the image files in the given directory.
* *If no image files are available, returns an empty image array.
*/ public static Image[] readImageFiles(String directory) { String[] files = readImageFileNames(directory); int length = files.length; Image[] images = new Image[length]; for (int i = 0; i < length; i++) images[i] = new ImageIcon(directory + "/" + files[i]).getImage(); return images; } /** *The method that reads the image file names in the given directory.
* *If no image files are available, returns an empty string array.
*/ public static String[] readImageFileNames(String directory) { if (directory == null) return new String[0]; File imagesDirectory = new File(directory); String[] files = imagesDirectory.list(imageFilter); if (files == null) return new String[0]; return files; } }