日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

文件IO-Properties

發(fā)布時間:2024/10/5 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 文件IO-Properties 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

java.lang.Object
繼承者 java.util.Dictionary<K,V>
繼承者 java.util.Hashtable<Object,Object>
繼承者 java.util.Properties
所有已實現(xiàn)的接口:
Serializable, Cloneable, Map<Object,Object>

1.構造方法

Properties();Properties(Properties default):創(chuàng)建一個帶有默認值的空屬性列表

2.主要方法:

getProperty(String key)通過指定的鍵獲取屬性,返回的是一個字符串load(InputStream inStream)從輸入流中讀取屬性列表load(Reader reader)按簡單的面向行的格式從輸入字符流中讀取屬性列表setProperty(String key,String value),向列表中輸入鍵值對store(OutputStream os,String commit)將此 Properties 表中的屬性列表(鍵和元素對)寫入輸出流,commit為注釋store(Writer writer,String commit)將此 Properties 表中的屬性列表(鍵和元素對)寫入輸出字符stringPropertyNames();返回一個set集合的鍵值對字符串 public class Demo09 {public static void main(String[] args) {Properties properties = new Properties();properties.setProperty("zsh", "1");properties.setProperty("zms","2");properties.setProperty("sks","3");Set<String> strings = properties.stringPropertyNames();for(String key:strings){String value = properties.getProperty(key);System.out.println(key+"="+value);}} import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.Properties;public class Demo10 {public static void main(String[] args) throws IOException {Properties properties = new Properties();properties.setProperty("sks","180");properties.setProperty("zsh","170");FileWriter fileWriter = new FileWriter("G:" + File.separator + "demo.txt");properties.store(fileWriter,"sava data");fileWriter.close();} }

總結

以上是生活随笔為你收集整理的文件IO-Properties的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。