misunderstanding fileList (as I try to sort my file and store there names into String[])
in
Programming Questions
•
2 years ago
I'm trying to sort files in the data folder regarding their size. I made a list from a java function which has a filter (regarding file type for example ".jpg") and stores the list in a string[] (called fileList[])
I'm loading this file into a Pimage so I can acces its width and height and really sort comparin my sketch size
I'm doing this
Copy code
String[] fileList ;
String[] svgList ;
String[] lesmasquesX ;
String[] lesmasquesM ;
String[] lesmasquesS ;
int indexmasque = 0;
int indexmasqueS = 0;
int indexmasqueM = 0;
int indexmasqueX = 0;
...and later in the setup ...
String path = sketchPath + "/data";
fileList = listFileNames(path, txtFilter); //images
svgList = listFileNames(path, svgFilter); //fichiers SVG
println("nombre de fichiers jpg : " + fileList.length);
println("nombre de fichiers svg : " + svgList.length);
println
for (int i = 0; i < fileList.length; i++) {
println("element de fileList : " + fileList[i] + " & i= "+ i);
imcompare = loadImage(fileList[i]);
if (imcompare.width == width && imcompare.height == height){
lesmasquesM[indexmasqueM] = fileList[i]; // where the error stands
indexmasqueM++;
}
if (imcompare.width < width && imcompare.height < height){
lesmasquesS[indexmasqueS] = fileList[i];
indexmasqueS++;
}
if (imcompare.width > width || imcompare.height > height){
lesmasquesX[indexmasqueX] = fileList[i];
indexmasqueX++;
}
}
is there something wrong with
String[] lesmasquesM ;
should be
String[] lesmasquesM (); //??? ;)
?
I dont get it
1