java访问资源文件
来源:互联网 发布:文本转声音软件 编辑:程序博客网 时间:2024/05/01 10:16
import java.io.FileInputStream;
import java.io.FileOutputStream; import java.util.Properties;
public class PropertyEditor {
public static void main(String[] args) throws Exception {
Properties prop = new Properties();// 属性集合对象
FileInputStream fis = new FileInputStream("prop.properties");// 属性文件输入流 (相对于根目录下的文件名,要加上包名 “src/prop.properties”)
prop.load(fis);// 将属性文件流装载到Properties对象中
fis.close();// 关闭流
// 获取属性值,sitename已在文件中定义
System.out.println("获取属性值:sitename=" + prop.getProperty("sitename"));
// 获取属性值,country未在文件中定义,将在此程序中返回一个默认值,但并不修改属性文件
System.out.println("获取属性值:country=" + prop.getProperty("country", "中国"));
// 修改sitename的属性值
prop.setProperty("sitename", "中国");
// 添加一个新的属性studio
prop.setProperty("studio", "Boxcode Studio");
// 文件输出流
FileOutputStream fos = new FileOutputStream("prop.properties");
// 将Properties集合保存到流中
prop.store(fos, "Copyright (c) Boxcode Studio");
fos.close();// 关闭流
}
}
资源文件
sitename=/u4E2D/u56FD
siteurl=www.abcjava.com
studio=Boxcode Studio
- java访问资源文件
- java访问资源文件
- java访问资源文件
- java访问资源文件
- java访问资源文件
- java访问资源文件
- java访问资源文件
- java访问资源文件
- java访问资源文件Properties
- java访问资源文件 .properties
- java访问 HDFS文件资源
- 通过R.java文件访问资源
- Java中使用ResourceBundle访问资源文件(properties文件)
- Java中使用ResourceBundle访问资源文件(properties文件)
- Java中使用ResourceBundle访问资源文件(properties文件)
- java使用ResourceBundle访问资源文件(.properties文件)
- .NET访问资源文件
- SpringMVC访问资源文件
- 星球上最详细的AWR解析报告
- php网站mysql load_file/outfile与多语句注入总结
- 我的才储分析结果
- WCF for .NET CF快速入门
- AutoCAD .NET API基础(一) AutoCAD 对象层次结构(4)
- java访问资源文件
- strtok方法
- java.sql.SQLException: No operations allowed after connection closed.Connection was implicitly closed due to underlying exceptio
- 线程和线程对象
- java日期处理bean
- 虚
- DDE
- Asp.net中小技巧—服务器端Web控件与客户端Html控件交互
- raywenderlich-How To Make A Simple iPhone Game with Cocos2D Tutorial