Advertisement
Soulseller

java -pathrename Project - sortFileList

Sep 30th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. public static LinkedList<File> sortFileList (LinkedList<File> f,int maxEbene)
  2. {
  3.     LinkedList<File> sFL = new LinkedList<File>();
  4.    
  5.     char bs = '\\';
  6.     int actbslash = 0;
  7.     int lastbslash = 0;
  8.    
  9.     while(maxEbene != 0)
  10.     {
  11.         for(int i = 0; i < f.size();i++)
  12.         {
  13.             int anzbslash =-1;     
  14.             int lastindexofbslash = f.get(i).getPath().lastIndexOf(bs);
  15.                        
  16.             //While Schleife um die genaue Anazhl aller '/' Indizes zu finden und abzuspeichern.
  17.             do         
  18.             {          
  19.                 //Feststellen des "nächsten" '/' im Pfad              
  20.                 actbslash = f.get(i).getPath().indexOf(bs,lastbslash+1);       
  21.                 lastbslash = actbslash;         //Index des aktuellen '/' in das Array schreiben   
  22.                 anzbslash++;
  23.             }          
  24.             while(actbslash != lastindexofbslash); 
  25.        
  26.             if(maxEbene == anzbslash)
  27.             {          
  28.                 sFL.add(f.get(i));
  29.                 System.out.println(sFL.getLast());
  30.                 f.remove(i);               
  31.             }      
  32.         }
  33.        
  34.     maxEbene--;
  35.     }
  36.    
  37.     return sFL;
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement