java Properties
2024-08-28 04:58:03
txt文件操作
// txt文件操作
Properties prop = new Properties();
String s = "Height=200";
String s2 = "Width=15";
FileOutputStream fos = new FileOutputStream("properties.txt");
fos.write(s.getBytes());
fos.write("\r\n".getBytes());
fos.write(s2.getBytes()); FileInputStream fis = new FileInputStream("properties.txt");
prop.load(fis); // txt:从输入字节流读取
prop.list(System.out);
System.out.println(prop.get("Height"));
xml文件操作
// xml文件操作
Properties prop = new Properties();
prop.put("Height", "200");
prop.put("Width", "15");
FileOutputStream fos = new FileOutputStream("properties.xml");
prop.storeToXML(fos, "Properties Example"); // xml:输出流写入 FileInputStream fis = new FileInputStream("properties.xml");
prop.loadFromXML(fis); // xml:从输入流读取properties
prop.list(System.out); Set<String> set = prop.stringPropertyNames();
System.out.println(set)
最新文章
- C#调用Win32API
- Mybats中字符串判断
- CodeForces 515C. Drazil and Factorial
- structs2之多文件上传
- Javascript 基础知识学习--javascript中的参数传递都是按值传递的
- MVC模式的学生信息增删改查
- java Clone()克隆
- HasMap
- SQL AlawaysOn 之一:安装域控制器
- 老李分享:Mac快捷键
- javaWEB之Servlet
- Dockerfile中CMD和ENTRYPOINT的区别
- 微信小程序页面跳转的问题(app.json中设置tarBar后wx.redirectTo和wx.navigateTo均不能实现跳转到指定的页面)
- Java数据类型之byte、char
- 【HNOI 2017】大佬
- 关于C语言内存的一些理解
- HTML&;javaSkcript&;CSS&;jQuery&;ajax(七)
- Mac系统下安装PyCharm
- Spark简介及其在ubuntu下的安装使用
- IIS------如何占用80端口
热门文章
- Azure系列2.1.7 —— BlobRequestOptions
- [转帖]分布式Unique ID的生成方法一览
- 逻辑斯特回归tensorflow实现
- 【apache2】AH00543: httpd: bad user name apache
- Python--文件、文件夹、压缩包、处理模块shutil
- URL &; QRcode auto generator
- Delphi之TStrings和TStringLists类
- 一、Dev单元格
- vue-cli: preset预设
- Codeforces Round #539 Div. 1