JAL-3949 fixed failing commandlinetests due to more output and line count limit
[jalview.git] / src / jalview / util / LaunchUtils.java
1 package jalview.util;
2
3 import java.io.File;
4 import java.io.FileInputStream;
5 import java.io.FileNotFoundException;
6 import java.io.IOException;
7 import java.util.Properties;
8
9 public class LaunchUtils
10 {
11
12   public static void loadChannelProps(File dir)
13   {
14     ChannelProperties.loadProps(dir);
15   }
16
17   private static Properties userPreferences = null;
18
19   public static String getUserPreference(String key)
20   {
21     if (userPreferences == null)
22     {
23       String channelPrefsFilename = ChannelProperties
24               .getProperty("preferences.filename");
25       if (channelPrefsFilename == null)
26       {
27         return null;
28       }
29       File propertiesFile = new File(System.getProperty("user.home"),
30               channelPrefsFilename);
31       if (!propertiesFile.exists())
32       {
33         return null;
34       }
35       try
36       {
37         userPreferences = new Properties();
38         userPreferences.load(new FileInputStream(propertiesFile));
39       } catch (FileNotFoundException e)
40       {
41         // didn't find user preferences file
42         return null;
43       } catch (IOException e)
44       {
45         System.err.println(e.getMessage());
46         return null;
47       }
48     }
49     return userPreferences.getProperty(key);
50   }
51
52   public static boolean getBooleanUserPreference(String key)
53   {
54     return Boolean.parseBoolean(getUserPreference(key));
55   }
56 }