???????????????????????????prop.properties
????baseFilePath=D:/kuanter/resource
????tesx=abcd
??????????????????????????????Properties??????У?????load???????????InputStream??????????????? InputStream??????FileInputStream??????????????Properties?????У????prop.properties??·??????????FileInputStream(String name)????????
????Properties prop = new Properties();//??????????
????FileInputStream fis = new FileInputStream("prop.properties");//?????????
????prop.load(fis);//???????????????Properties??????
????1.//??????????baseFilePath????????ж???
????2.System.out.println("??????????baseFilePath=" + prop.getProperty("baseFilePath"));
????3.//??????????countryδ??????ж??壬?????????з????????????????????????????
????4.System.out.println("??????????country=" + prop.getProperty("country"?? "?й?"));
???????????????????????????????????????????????????μ????????????????????????????????setProperty(String key?? String value)????????????????????д????????key?????????key?????????????????????key??????????????????????????????????Properties??????Hashtable?????????????Hashtable??put??putAll???????棬????????????????????????????????????÷??????????????? Strings ????????????? setProperty ???????????“??Σ??”?? Properties ???????????? String ????????????? store ?? save ???????????y??????????????????????????????????????????

 

//???baseFilePath???????
prop.setProperty("baseFilePath"?? "Boxcode");
//???????μ?????studio
prop.setProperty("studio"?? "Boxcode Studio");
//????????
FileOutputStream fos = new FileOutputStream("prop.properties");
//??Properties??????浽????
prop.store(fos?? "Copyright (c) Boxcode Studio");
fos.close();//?????

???????????????ζ?д???????????????????????к????????????????load??store???????????ISO-8859-1????????д??????????????ILatin1 ????????Щ????????????????Latin1 ????????Щ???????????????????????????????????????????????У?????????????????????????????????????????????????????????????????????????????????????????????JAVA?????????setProperty????????????????????????????store??????????? unicode??????????????????unicode??????????????????????????????????GBK???????????????????????

??????????????е??????????д

package TestPropertis;
//import java.io.FileInputStream;
//import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
//import java.net.URL;
import java.util.Properties;
/**
* TODO
* @author admin
* @date 2012-11-22 ????05:17:28
*/
public class ReadWirtePropertis {
public static void main(String[] args) {
Properties pro = new Properties();//??????????
//      URL url = Thread.currentThread().getContextClassLoader().getResource("prop.properties");//?????????????·??
InputStream path =Thread.currentThread().getContextClassLoader().getResourceAsStream("prop.properties");//???·???????????
//      try {
//          FileInputStream fis = new FileInputStream("??????????????????");
try {
//              pro.load(fis);//???????????????Properties??????
pro.load(path);
//              fis.close();
System.out.println(pro.getProperty("baseFilePath"));
pro.setProperty("shuzi"?? "1111");//????????????
pro.setProperty("shuzi"?? "222");//?????????
System.out.println(pro.getProperty("shuzi"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//      } catch (FileNotFoundException e) {
//          // TODO Auto-generated catch block
//          e.printStackTrace();
//      }
}
}