1 import java.io.BufferedReader; 2 import java.io.FileInputStream; 3 import java.io.IOException; 4 import java.io.InputStream; 5 import java.io.InputStreamReader; 6 import java.util.Properties; 7 8 /** 9 * @author Chase QQ: 594126573 10 * @version 创建时间:2012-5-11 下午02:28:36 11 * 类说明 12 */ 13 14 public class test { 15 public static void main(String[] args) { 16 17 test2(); 18 } 19 20 public static void test1() throws IOException{ 21 String file = "E:\\workspace7.01\\JspFileUpload\\src\\System.properties"; 22 InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(file),"utf-8"); 23 BufferedReader br = new BufferedReader(inputStreamReader); 24 String s; 25 try { 26 while ((s = br.readLine())!= null) { 27 System.out.println(s); 28 } 29 } catch (Exception e) { 30 e.printStackTrace(); 31 } 32 33 } 34 35 public static void test2(){ 36 InputStream inputStream = new test().getClass().getClassLoader().getResourceAsStream("System.properties"); 37 Properties p = new Properties(); 38 try { 39 p.load(inputStream); 40 } catch (IOException e1) { 41 e1.printStackTrace(); 42 } 43 System.out.println("TgUpLoadPath"+p.getProperty("TgUpLoadPath")+",TgUpLoadPath:"+p.getProperty("TgUpLoadPath")); 44 } 45 46 }