KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

15 public class TextBackup implements ScreenPrinterInterface
16 {
17     private String JavaDoc home;
18     
19     /** Creates a new instance of TextBackup */
20     public TextBackup(String JavaDoc home)
21     {
22         this.home = home;
23     }
24     
25     public void backup()
26     {
27         System.out.println("This utility will backup all the essential system configuration files. Press ENTER to continue");
28         
29         try
30         {
31             BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
32             reader.readLine();
33             
34             File f = null;
35             if (home == null)
36             {
37                 f = new File(".");
38             }
39             else
40             {
41                 f = new File (home);
42             }
43             
44             String JavaDoc abs_path = f.getAbsolutePath();
45             if (abs_path.endsWith(File.separator + ".") == true)
46             {
47                 abs_path = abs_path.substring(0, abs_path.length() - 2);
48             }
49             
50             // check if this is indeed ACE_HOME
51
f = new File(abs_path, "sql/init_ace.sql.orig");
52             if (f.exists() == false)
53             {
54                 System.out.println("You have not started this utility from the ACE Home folder. Backup cannot be done");
55             }
56             else
57             {
58                 // start the backup process.
59
BackupFiles backup = new BackupFiles();
60                 String JavaDoc error = backup.backup(abs_path, this);
61                 if (error != null)
62                 {
63                     System.out.println (error);
64                 }
65                 else
66                 {
67                     System.out.println("Backup completed.");
68                 }
69             }
70             
71         }
72         catch (IOException ex)
73         {
74             System.out.println("An IO error occured: " + ex.getMessage());
75         }
76         
77         System.exit(0);
78     }
79     
80     public void print(String JavaDoc message)
81     {
82         System.out.print(message);
83     }
84     
85     public void println(String JavaDoc message)
86     {
87         System.out.println(message);
88     }
89     
90 }
91
Popular Tags