So I found the getImageCount function in another forum on the internet (don't remember which one)...but anyway, it's not working the way I'd like. It's looping through the folder but never incrementing count correctly (the getPath() shows each file in the folder)...but count stays at 0...I've tried having count as a class variable and an instance variable, but it doesn't ever increment...can someone explain why this isn't working correctly?
Thanks!
Leslie
Have you met Hardy Heron?
Thanks!
Code:
import java.io.*;
public class ScannedImageFolder {
private File currentFolder;
private int imageCount;
private boolean timeToChange = false;
int count = 0;
ScannedImageFolder(String c){
currentFolder = new File(c);
imageCount = getImageCount(currentFolder);
settimeToChange();
}
public int getImageCount(){
return imageCount;
}
public File getCurrentFolder (){
return currentFolder;
}
public void setCurrentFolder(String c){
currentFolder = new File(c);
}
[b]private int getImageCount(File file) {
System.out.println("file getPath = " + file.getPath()); //shows correct file names
File[] files = file.listFiles();
if (files != null)
{
for (File f: files)
{
count += getImageCount(f);
}
}
System.out.println("current count = " + count);
return count;
}[/b]
private void settimeToChange () {
if (imageCount > 12000){
timeToChange = true;
}
}
}
public class ScannedImageFolderTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ScannedImageFolder test = new ScannedImageFolder("\\\\srvname\\imaging\\Citationimages\\00000036\\");
System.out.println("current folder:" + test.getCurrentFolder());
System.out.println("image count:" + test.getImageCount());
}
}
Leslie
Have you met Hardy Heron?