KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quikj > application > utilities > postinstall > BackupFiles


1 /*
2  * BackupFiles.java
3  *
4  * Created on November 12, 2003, 7:13 AM
5  */

6
7 package com.quikj.application.utilities.postinstall;
8
9 import java.util.*;
10 import java.io.*;
11 /**
12  *
13  * @author amit
14  */

15 public class BackupFiles
16 {
17     
18     /** Creates a new instance of BackupFiles */
19     public BackupFiles()
20     {
21     }
22
23     public String JavaDoc backup(String JavaDoc 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             // get a list of the files
34
String JavaDoc[] suffixes =
35             {
36                 ".htm", ".html", ".xml"
37             };
38             
39             String JavaDoc[] 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 JavaDoc path = (String JavaDoc)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 JavaDoc ex)
63         {
64             return "IO error occured while backing up system files";
65         }
66     }
67 }
68
Popular Tags