1 6 7 package com.quikj.application.utilities.postinstall; 8 9 import java.util.*; 10 import java.io.*; 11 15 public class BackupFiles 16 { 17 18 19 public BackupFiles() 20 { 21 } 22 23 public String backup(String base, ScreenPrinterInterface out) 24 { 25 try 26 { 27 File top = new File(base); 28 if (top.isDirectory() == false) 29 { 30 return "The top-level folder " + base + " is not a folder"; 31 } 32 33 String [] suffixes = 35 { 36 ".htm", ".html", ".xml" 37 }; 38 39 String [] excludes = 40 { 41 "data/global/www/aceapp/data", 42 "data/global/www/aceapp/doc", 43 "data/global/www/aceapp/license", 44 "src", 45 "sh" 46 }; 47 48 ArrayList file_list = new ArrayList(); 49 FileUtils.list(top, top, suffixes, excludes, file_list); 50 Iterator iter = file_list.iterator(); 51 52 while (iter.hasNext() == true) 53 { 54 String path = (String )iter.next(); 55 out.println("Renaming file " + path + " to " + path + ".bak"); 56 FileUtils.copy (path, path + ".bak"); 57 } 58 59 60 return null; 61 } 62 catch (Exception ex) 63 { 64 return "IO error occured while backing up system files"; 65 } 66 } 67 } 68 | Popular Tags |