package ng.db; import java.io.*; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Properties; public class NGFunction { public static Properties getProperties() throws IOException{ Properties properties = new Properties(); // ʹÓÃClassLoader¼ÓÔØpropertiesÅäÖÃÎļþÉú³É¶ÔÓ¦µÄÊäÈëÁ÷ InputStream in =new java.io.FileInputStream("C:\\Program Files\\NorthGlass\\db.config"); // ʹÓÃproperties¶ÔÏó¼ÓÔØÊäÈëÁ÷ try{ properties.load(in); } finally{ if(in!=null) in.close(); } return properties; //»ñÈ¡key¶ÔÓ¦µÄvalueÖµ } public static String dateFormat(String format,java.util.Date date){ SimpleDateFormat f=new SimpleDateFormat(format); return f.format(date); } public static java.util.Date dateParse(String format,String date) throws ParseException{ SimpleDateFormat f=new SimpleDateFormat(format); return f.parse(date); } public static String getFileContent(String path) throws IOException{ FileReader reader=null; try{ reader= new FileReader(path); String s= getReaderContent(reader); reader.close(); reader=null; return s; } finally{ if(reader!=null) reader.close(); } } public static String getReaderContent(java.io.Reader reader) throws IOException{ BufferedReader in=null; try{ in=new BufferedReader(reader); StringBuffer jsonStr=new StringBuffer(); String str=""; while((str=in.readLine())!=null){ jsonStr.append(str); } in.close(); in=null; return jsonStr.toString(); } finally{ if(in!=null) in.close(); } } }