View Javadoc

1   package org.wcb.installs;
2   
3   import java.io.File;
4   import java.io.PrintWriter;
5   import java.io.BufferedWriter;
6   import java.io.FileWriter;
7   import java.util.Vector;
8   
9   public class OSSystem {
10      
11      protected static String SEP = System.getProperty("file.separator");
12      protected static String LINE_SEP = System.getProperty("line.separator");
13  
14      protected Vector jarFilesExist(String homeDir){
15  	Vector errorMessage =new Vector();
16  	if(!checkJarExists(homeDir+SEP+"comm.jar")) {
17  	    System.out.println("Comm.jar is not in directory");
18  	    errorMessage.addElement("comm.jar");
19  	}	
20  	if(!checkJarExists(homeDir+SEP+"swingall.jar")){
21  	    System.out.println("swingall.jar is not in directory");
22  	    errorMessage.addElement("swingall.jar");
23  	}
24  	return errorMessage;
25      }
26  
27      private boolean checkJarExists(String absoluteJarName){
28  	File jarFile = new File(absoluteJarName);
29  	if(jarFile.exists())
30  	    return true;
31  	return false;
32      }
33    
34      /*** 
35       *  Attempt to make a brand new directory 
36       *  a botched attempt will return a false;
37       */
38      public boolean createNewDirectory(String dirname){	
39  	File newName = new File(dirname);	
40  	return newName.mkdir();
41      }
42       /*** 
43       *  Check if the Directory exists 
44       *  If it does then return true.
45       */
46      public boolean directoryExists(String dirname){	
47  	File newName = new File(dirname);	
48  	return newName.exists();
49      }
50  
51      /***
52       * This takes a file name and writes the string information
53       * out to the file.
54       */
55      public void writeFile(String fileText, String fileNameOut) {
56  	System.out.println("File name writing = "+fileNameOut);
57  	try {
58  	    PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(fileNameOut)));    
59  	    out.println(fileText);
60              out.flush();
61  	    out.close();
62          } catch (Exception e) { e.printStackTrace();}
63      }
64  }