Properties 使用,注意编码
private static void setConfig(){
try {
// String path = System.getProperty("user.dir") + "\\dbpool.properties";
String path = "./lib/setting.txt";
// FileInputStream is = new FileInputStream(path);
Properties props = new Properties();
// props.load(is);
props.setProperty("dslname",textField.getText().trim());
props.setProperty("dslacc",textField_1.getText().trim());
props.setProperty("dslpsw",textField_2.getText().trim());
//props.store (is);
PrintStream fW = new PrintStream(new File(path));
props.list(fW );
// timeout = Integer.parseInt(props.getProperty("timeout"));
// waitforresult=Integer.parseInt(props.getProperty("waitforresult"));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.err.println("�����ļ��Ҳ���");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.err.println("��ȡ�����ļ�����");
}
}
private static void readConfig(){
try {
// String path = System.getProperty("user.dir") + "\\dbpool.properties";
String path = "./lib/setting.txt";
FileInputStream is = new FileInputStream(new File(path));
// FileInputStream.
Properties props = new Properties();
InputStreamReader reader = new InputStreamReader(is,"UTF-8");
props.load(reader);
//props.load(is);
dslname=props.getProperty("dslname");
dslacc=props.getProperty("dslacc");
dslpsw=props.getProperty("dslpsw");
textField.setText(new String(dslname.getBytes("utf-8"),"utf-8"));
textField_1.setText(dslacc);
textField_2.setText(dslpsw);
// timeout = Integer.parseInt(props.getProperty("timeout"));
// waitforresult=Integer.parseInt(props.getProperty("waitforresult"));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.err.println("�����ļ��Ҳ���");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.err.println("��ȡ�����ļ�����");
}
}
Properties 使用,注意编码的更多相关文章
- properties中的编码如何生成:例如\u7AD9\u70B9这种。
在eclipse中的properties中的一种编码,例如\u7AD9\u70B9,是如何自动生成的. 这种编码方式当你要增加某个字段的时候,也要相应的添加这种编码方式下的格式,具体方法如下:
- properties中的编码如何生成:例如\u7AD9\u70B9这种
在eclipse中的properties中的一种编码,例如\u7AD9\u70B9,是如何自动生成的. 这种编码方式当你要增加某个字段的时候,也要相应的添加这种编码方式下的格式,具体方法如下:
- properties的编码问题
1.在eclipse中,如果不专门设置,properties文件的编码是ISO-8859-1,最好将其改为UTF-8 2.当properties文件的编码改为UTF-8还不够,Spring的conte ...
- Java读写资源文件类Properties
Java中读写资源文件最重要的类是Properties 1) 资源文件要求如下: 1.properties文件是一个文本文件 2.properties文件的语法有两种,一种是注释,一种属性配置. 注 ...
- unicode编码和中国的相互转换
如果你的原始文件1.properties(该文件的编码中国).要转换unicode的 在cmd通过进入你在哪里在这种类型的文件夹: native2ascii -encoding gb2312 1.pr ...
- JAVA提高十三:Hashtable&Properties深入分析
最近因为一些琐碎的事情,导致一直没时间写博客,正好今天需求开发完的早,所以趁早写下本文,本文主要学习的是Hashtable的分析,因为上面一篇文章研究的是HashMap,而Hashtable和Hash ...
- excel中的数据导出为properties和map的方法
在做项目的过程中,经常需要处理excel数据,特别是和业务人员配合时,业务人员喜欢使用excel处理一些数据,然后交给我们技术人员进行程序处理.利用POI读取写入excel数据,是经常使用的一个情景. ...
- jdbc.properties+web.xml
1. jdbc.properties #\u8FDE\u63A5\u8BBE\u7F6E[左边是properties被IDE编码后的结果] jdbc.driverClassName=com.mysql ...
- 解决Eclipse中.properties文件中文乱码问题
在.properties文件写注释时,发现中文乱码了,由于之前在idea中有见设置.properties文件的编码类型,便找了找乱码原因 在中文操作系统中,Eclipse中的Java类型文件的编码的默 ...
- java读取properties中文乱码
1 确认properties文件的编码是utf-8 2 采用流的方式读取文件,设置编码为utf-8 public class ErrorCodeConfig { static Properties p ...
随机推荐
- ECOS-认证地址
ECOS系统授权认证,需要和Shopex认证中心互联.当服务器DNS无效时.需要绑定host强行解析服务器强行解析以下vim /etc/hosts 122.144.135.142 service.sh ...
- 经典.net面试题目(1)
1. 简述 private. protected. public. internal 修饰符的访问权限. 答 . private : 私有成员, 在类的内部才可以访问. protected : 保 ...
- kvm and virtualbox running side by side
http://dedoimedo.com/computers/kvm-virtualbox.html
- 打开另外一个App
/** * 打开一个app * * @param packageName * @param data * @return */ public static boolean lanuchApp(Cont ...
- sudo su– user
[root@localhost ~] # visudo –f /etc/sudoers 在文件中的root账户下添加需要切换root账户的账户 root ALL=(ALL) ALL user ALL= ...
- Petit FatFs
FatFs is a generic FAT/exFAT file system module for small embedded systems. The FatFs module is writ ...
- JavaScript 常用功能实现一览(一)
摘自于网络:http://www.cnblogs.com/joinger/articles/1506482.html 适合阅读范围:对JavaScript一无所知-离精通只差一步之遥的人基础知识:HT ...
- 【多重背包】 poj 2392
转自:http://blog.csdn.net/wangjian8006 题目大意:有一头奶牛要上太空,他有很多种石头,每种石头的高度是hi,但是不能放到ai之上的高度,并且这种石头有ci个将这些石头 ...
- NumPy基础:数组和矢量计算
今天被老板fire了,还是继续抄书吧,安抚我受伤的小心脏.知识还是得慢慢积累,一步一个脚印,这样或许才是最快的捷径. ------2015-2-16-------------------------- ...
- Flask architecture
论文The Flask Security Architecture: System Support for Diverse Security Policies 介绍了Flask architectur ...