Convert from int[] to int
in
Programming Questions
•
1 year ago
Hi all,
I'm would like to use the build-in java class
java.io.File to collect the number of .jpg in my data folder.
When I want to use it in my code, to set a int, I got a message error "Cannot convert int[] to int"
I want to convert it to a int because my code'd display randomly one of the jpg from my data folder.
The error comes from line 21.
- void setup(){
- // have a look in the data folder
- java.io.File folder = new java.io.File(dataPath(""));
- // this is the filter (returns true if file's extension is .jpg)
- java.io.FilenameFilter jpgFilter = new java.io.FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.toLowerCase().endsWith(".jpg");
- }
- };
- // list the files in the data folder
- String[] numberofpics = folder.list(jpgFilter);
- // get the number of jpg files
- println(numberofpics.length + " jpg files in specified directory");
- int numberofpics_int = int (numberofpics);
- xPic = numberofpics_int;
- //Pic loading
- Pic = random(1,xPic);
- int PicFragNumber = int (Pic);
- img = loadImage("Pic_" + PicFragNumber +".jpg");
Does anyone know how to do this magic trick?
Thank's a lot.
1