Re-Arranging file array contents using Java -


i have file array have list of file names folder.

e.g.

file file = new file("/path"); file[] arr = file.listfiles(); 

so arr has file names inside file path.

say arr[folder1 , folder2, folder3].

also have string array list contains ( folder3 , folder1 , folder2).

i need change arr contents per arrraylist order.

(i.e) after processing arr have [ folder3 , folder1 , folder2].

i need because , have read folders based on hierarchy.

am new please how can achieve it.

if have folder names string list in desired order, why use file.listfiles()?

just create file objects names in order listed, this:

list< string > arraylist = arrays.aslist("folder3", "folder1", "folder2");  file parent = new file("/path"); file[] arr = new file[arraylist.size()];  ( int = 0; < arr.length; i++ )     arr[i] = new file(parent, arraylist.get(i));  // arr contain file objects in order listed in arraylist 

Comments

Popular posts from this blog

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -