Properties 主要方法和属性讲解
Properties 重要方法和属性讲解
Properties 重要方法和属性讲解
公用方法:
* 返回值:String
方法:getProperty(String name, String defaultValue)
解释:通过指定的 “name“ 即Key,搜索属性,参数二为默认值,即通过Key找不到文件中的属性时,要返回的默认值。
* 返回值:String
方法:getProperty(String name)
解释:通过指定的 ”name“ 即为 Key,搜索属性,没有返回默认值。
* 无返回值:void
方法:list(PrintStream out)
解释:通过PrintStream 列出可读的属性列表
* 无返回值:void
方法:list(PrintWriter writer)
解释:通过PrintStream 列出可写的属性列表
* 无返回值:synchronized void
方法:load(InputStream in)
解释:从指定的 ”inputStream “ 即输出流,加载properties
* 无返回值:synchronized void
方法:loadFromXML(InputStream in)
解释:从指定的 "InputStream" 即输出流,加载一个以XML形式的 Properties
* 返回值:Enumeration<?>
方法:propertyNames()
解释:返回所有包含在文件里面的属性名称
* 无返回值:void
方法:save(OutputStream out, String comment)
解释:注意,这种保存方法己经过时,Google 不推荐使用此种写法,这种方法忽略任何IO 异常,所以在实际操作过程中,可能会发生不必要的异常。
* 返回值:object
方法:setProperty(String name, String value)
解释:设置属性,保存一个”键-值“对的属性。
* 无返回值:synchronized void
方法:store(OutputStream out, String comment)
解释:通过 FileOutputStream 打开对应的程序文件,然后通过Store 保存之前 Properties 打包好的数据。这里备注可以为空。
* 无返回值:void
方法:storeToXML(OutputStream os, String comment)
解释:通过FileOutputStream 打开对应的程序文件,将打包好的数据写入到XML文件。
* 无返回值:synchronized void
方法:storeToXML(OutputStream os, String comment, String encoding)
解释:通过FileOutputStream 打开对应的程序文件,将打包好的数据写入到XML文件,第三个参数可以指定编码。
Properties 重要方法和属性讲解
公用方法:
* 返回值:String
方法:getProperty(String name, String defaultValue)
解释:通过指定的 “name“ 即Key,搜索属性,参数二为默认值,即通过Key找不到文件中的属性时,要返回的默认值。
* 返回值:String
方法:getProperty(String name)
解释:通过指定的 ”name“ 即为 Key,搜索属性,没有返回默认值。
* 无返回值:void
方法:list(PrintStream out)
解释:通过PrintStream 列出可读的属性列表
* 无返回值:void
方法:list(PrintWriter writer)
解释:通过PrintStream 列出可写的属性列表
* 无返回值:synchronized void
方法:load(InputStream in)
解释:从指定的 ”inputStream “ 即输出流,加载properties
* 无返回值:synchronized void
方法:loadFromXML(InputStream in)
解释:从指定的 "InputStream" 即输出流,加载一个以XML形式的 Properties
* 返回值:Enumeration<?>
方法:propertyNames()
解释:返回所有包含在文件里面的属性名称
* 无返回值:void
方法:save(OutputStream out, String comment)
解释:注意,这种保存方法己经过时,Google 不推荐使用此种写法,这种方法忽略任何IO 异常,所以在实际操作过程中,可能会发生不必要的异常。
* 返回值:object
方法:setProperty(String name, String value)
解释:设置属性,保存一个”键-值“对的属性。
* 无返回值:synchronized void
方法:store(OutputStream out, String comment)
解释:通过 FileOutputStream 打开对应的程序文件,然后通过Store 保存之前 Properties 打包好的数据。这里备注可以为空。
* 无返回值:void
方法:storeToXML(OutputStream os, String comment)
解释:通过FileOutputStream 打开对应的程序文件,将打包好的数据写入到XML文件。
* 无返回值:synchronized void
方法:storeToXML(OutputStream os, String comment, String encoding)
解释:通过FileOutputStream 打开对应的程序文件,将打包好的数据写入到XML文件,第三个参数可以指定编码。