View Javadoc
1 package org.argosfields.util; 2 3 import java.io.File; 4 5 import org.apache.commons.logging.Log; 6 import org.apache.commons.logging.LogFactory; 7 8 /*** 9 * SpecialFolders.java 10 * @author Xavier Cho 11 * @version $Revision: 1.5 $ $Date: 2004/04/15 05:42:45 $ 12 */ 13 public final class SpecialFolders { 14 private static Log log = LogFactory.getLog(SpecialFolders.class); 15 16 private static String applicationHome; 17 private static String preferenceFilePath; 18 19 private SpecialFolders() { 20 } 21 22 private static void checkDirectory(final String path) { 23 File dir = new File(path); 24 if (!dir.exists()) { 25 if (log.isInfoEnabled()) { 26 log.info("Creating directory " + dir.getAbsolutePath()); 27 } 28 dir.mkdirs(); 29 } 30 } 31 32 public static String getUserHomeDirectory() { 33 return System.getProperty("user.home"); 34 } 35 36 public static String getWorkDirectory() { 37 return System.getProperty("user.dir"); 38 } 39 40 public static String getApplicationHomeDirectory() { 41 if (applicationHome == null) { 42 synchronized (SpecialFolders.class) { 43 StringBuffer buffer = new StringBuffer(); 44 buffer.append(getUserHomeDirectory()); 45 buffer.append(File.separator); 46 buffer.append(".argosfields"); 47 48 applicationHome = buffer.toString(); 49 50 if (log.isInfoEnabled()) { 51 log.info("Application home dir - " + applicationHome); 52 } 53 54 checkDirectory(applicationHome); 55 } 56 } 57 58 return applicationHome; 59 } 60 61 public static String getPreferenceFilePath() { 62 if (preferenceFilePath == null) { 63 synchronized (SpecialFolders.class) { 64 StringBuffer buffer = new StringBuffer(); 65 buffer.append(getApplicationHomeDirectory()); 66 buffer.append(File.separator); 67 buffer.append("preferences.properties"); 68 69 preferenceFilePath = buffer.toString(); 70 71 if (log.isInfoEnabled()) { 72 log.info("Preference file path - " + preferenceFilePath); 73 } 74 } 75 } 76 77 return preferenceFilePath; 78 } 79 }

This page was automatically generated by Maven