1 4 package chipchat; 5 6 import java.io.InputStream ; 7 import java.util.Properties ; 8 9 13 public final class Env extends Properties { 14 18 private static Env instance; 19 20 24 public static Env getInstance() { 25 if (instance != null) { 26 return instance; 27 } else { 28 makeInstance(); 29 return instance; 30 } 31 } 32 33 36 private static synchronized void makeInstance() { 37 if (instance == null) { 38 instance = new Env(); 39 } 40 } 41 42 45 private Env() { 46 setProperty("ChipChat.maxRoom", "100"); 48 setProperty("Communicator.serverName", "ChipChat"); 49 setProperty("Communicator.adminpasswd", "adminpw"); 50 51 InputStream is = getClass().getResourceAsStream("chipchat.properties"); 52 try { 53 load(is); 54 } catch (Exception e) { 55 System.err.println( 56 "Error : Can't read the properties file.\r\n" 57 + "Make sure chipchat.property is in the CLASSPATH"); 58 return; 59 } 60 } 61 } 62 | Popular Tags |