class="java">import java.io.IOException; import java.io.InputStream; import java.util.Properties; /** * @Desc:读取XXproperties工具类 * @Filename:ReadPropertiesUtil.java * @Author:wyj * @Date:2012-10-17下午06:22:10 */ public class ReadPropertiesUtil { private static String url; private static String userName; private static String passWord; private ReadPropertiesUtil() { } static { Properties prop = new Properties(); InputStream in = ReadPropertiesUtil.class .getResourceAsStream("/sm.properties"); try { prop.load(in); url = prop.getProperty("sm.url").trim(); userName = prop.getProperty("sm.username").trim(); passWord = prop.getProperty("sm.password").trim(); } catch (IOException e) { e.printStackTrace(); } finally { if (in != null) { try { in.close(); } catch (IOException e) {} } } } public static String getUrl() { return url; } public static String getUserName() { return userName; } public static String getPassWord() { return passWord; } }
?