Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected static boolean performActionInFileFromStartToEndAndCloseAction(File file, ItemAction action,int startIndex, int endIndex, ItemAction close){
- try {
- if(file.isDirectory()){
- int count = startIndex;
- File[] contents = file.listFiles();
- if (endIndex == -1){
- //bit messy...but is an internal signal to process all items
- endIndex = contents.length-1;
- }
- File item;
- for(int k = startIndex; k < contents.length && k <= endIndex; k++){
- item = contents[k];
- System.out.println("Start folder "+count +" "+item.getName());
- if(!action.doAction(item))
- return false;
- System.out.println("Completed folder "+count+ " ");
- count++;
- }
- close.doAction(file);
- }
- }catch(Exception e) {
- System.err.println("Error!");
- e.printStackTrace();
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement