java store()_Java.util.Properties.store()
描述
所述java.util.Properties.store(OutputStream out,String comments)方法在適合于裝載一個格式轉(zhuǎn)換成使用所述負(fù)載的屬性表在該屬性表寫此屬性列表(key and element )到輸出流(InputStream的)方法。
聲明
以下是java.util.Properties.store()方法的聲明
public void store(OutputStream out,String comments)
參數(shù)
out - 輸出流。
comments - 屬性列表的描述。
返回值
此方法返回此屬性列表中指定鍵的先前值,如果沒有,則返回null。
異常
IOException - 如果將此屬性列表寫入指定的輸出流會拋出IOException。
ClassCastException - 如果此Properties對象包含任何不是字符串的鍵或值。
NullPointerException - 如果out為null。
實例
以下示例顯示了java.util.Properties.store()方法的用法。
package com.tutorialspoint;
import java.io.IOException;
import java.util.*;
public class PropertiesDemo {
public static void main(String[] args) {
Properties prop = new Properties();
// add some properties
prop.setProperty("Height", "200");
prop.put("Width", "1500");
// print the list
System.out.println("" + prop);
try {
// store the properties list in an output stream
prop.store(System.out, "PropertiesDemo");
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
讓我們編譯并運行上面的程序,這將產(chǎn)生以下結(jié)果
{Width=1500, Height=200}
#PropertiesDemo
#Sat Jun 30 02:30:14 EEST 2012
Width=1500
Height=200
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的java store()_Java.util.Properties.store()的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SQLite学习手册(在线备份)
- 下一篇: SQLite学习手册(内存数据库)