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

歡迎訪(fǎng)問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

文件IO-Properties

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

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

1.構(gòu)造方法

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

2.主要方法:

getProperty(String key)通過(guò)指定的鍵獲取屬性,返回的是一個(gè)字符串load(InputStream inStream)從輸入流中讀取屬性列表load(Reader reader)按簡(jiǎn)單的面向行的格式從輸入字符流中讀取屬性列表setProperty(String key,String value),向列表中輸入鍵值對(duì)store(OutputStream os,String commit)將此 Properties 表中的屬性列表(鍵和元素對(duì))寫(xiě)入輸出流,commit為注釋store(Writer writer,String commit)將此 Properties 表中的屬性列表(鍵和元素對(duì))寫(xiě)入輸出字符stringPropertyNames();返回一個(gè)set集合的鍵值對(duì)字符串 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();} }

總結(jié)

以上是生活随笔為你收集整理的文件IO-Properties的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

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