Properties 生成文件

package List;

import java.io.File;
import java.io.FileOutputStream;
import java.util.Properties;

public class PropertiesDemo01 {
    public static void main(String[] args) {
        Properties properties = new Properties();
        properties.setProperty("BJ", "北京");
        properties.setProperty("SH", "上海");
        properties.setProperty("GZ", "廣州");
        File file = new File("d:"+File.separator+"area.properties");
        try{
            properties.store(new FileOutputStream(file), "Area Info");
        }catch (Exception e){
            e.printStackTrace();
        }

        File file1 = new File("d:"+File.separator+"area.XML");
        try{
            properties.storeToXML(new FileOutputStream(file1), "Area Info");
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
相關文章
相關標籤/搜索