1 package sample.google.common.util; 2 3 import java.io.IOException ; 4 import java.io.InputStream ; 5 import java.util.Properties ; 6 7 24 public class PropertyLoader { 25 26 private static String googleKey; 27 private static String googleEndpointURL; 28 private static String googleEndpointServiceName; 29 30 static{ 31 try { 32 Properties prop = new Properties (); 33 Class clazz = new Object ().getClass(); 34 InputStream stream = clazz.getResourceAsStream("/sample/google/common/conf/key.properties"); 35 prop.load(stream); 36 37 googleKey = prop.getProperty("google.key"); 38 googleEndpointURL = prop.getProperty("google.url"); 39 googleEndpointServiceName = prop.getProperty("google.name"); 40 41 } catch (IOException e) { 42 System.exit(0); 43 } 44 45 } 46 public static String getGoogleKey() { 47 return googleKey; 48 } 49 50 public static String getGoogleEndpointURL() { 51 return googleEndpointURL; 52 } 53 54 public static String getGoogleEndpointServiceName() { 55 return googleEndpointServiceName; 56 } 57 58 public static void setGoogleKey(String googleKey) { 59 PropertyLoader.googleKey = googleKey; 60 } 61 62 } 63 | Popular Tags |