廖井涛
2024-03-04 eae17d27ec56a6b7887f5597335e38ca40273ef4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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();
        }
    }
    
    
 
 
 
}