国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

讀寫指定的屬性文件演示

2019-11-18 15:07:00
字體:
來源:轉載
供稿:網友


代碼:
import java.io.*;
import java.util.PRoperties;

public class PropertiesDemo {
  public static void main(String[] args)
  {
    String pFilename = System.getProperty("user.dir")
      + System.getProperty("file.separator") + "test.properties"; // 構造文件名
    Properties p = new Properties();  

    try
    {
      FileInputStream in = new FileInputStream(pFilename);  // 構造文件的輸入流
      p.load(in);           // 讀入屬性
      in.close();
    }
    catch(Exception e)
    {
      System.out.println("Error of create input stream");
    }

    System.out.println(p.getProperty("property1"));
    p.setProperty("property1","new value"); // 給property1賦新的值

    try
    {
      FileOutputStream out = new FileOutputStream(pFilename);
      p.store(out,"This file is a test"); // 設置屬性文件的文件頭信息
      out.flush();
      out.close();
    }
    catch(Exception e)
    {
      System.out.println("Error of write input stream");
    }
  }
}



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 来凤县| 龙游县| 富阳市| 海宁市| 博野县| 平遥县| 正镶白旗| 明星| 姜堰市| 张家界市| 新巴尔虎右旗| 伊金霍洛旗| 东至县| 恩施市| 清苑县| 建阳市| 平顶山市| 江永县| 临猗县| 威信县| 怀来县| 承德市| 阳曲县| 南召县| 吉林省| 榆树市| 陕西省| 六枝特区| 缙云县| 常德市| 合阳县| 资兴市| 元朗区| 东安县| 博爱县| 红河县| 永春县| 高淳县| 剑阁县| 灵山县| 黄龙县|