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 ...
随机推荐
- hdu_5777_domino(贪心)
题目链接:hdu_5777_domino 题意: 小白在玩一个游戏.桌子上有n张多米诺骨牌排成一列.它有k次机会,每次可以选一个还没有倒的骨牌,向左或者向右推倒.每个骨 牌倒下的时候,若碰到了未倒下的 ...
- Balancing Symbols
symbols匹配问题 #include<iostream> #include<string> using namespace std; struct Node { char ...
- psql 命令总结
1 登录数据库 Connection options: -h, --host=HOSTNAME database server host or socket directory (default: & ...
- Ajax交互,浏览器接收不到服务器的Json数据(跨域问题)
该问题的情景如下: 问题描述 Ajax的请求代码放在一台机器上,而服务器的java 路由程序放在另一个机子上,所以Ajax的url填写的是带"http://" 的地址,而不是相对 ...
- Log4j 简介及初步应用
使用2.5版本有问题,暂时没有解决,也许是JDK版本不兼容的原因.因此使用的是log4j-1.2.8.jar 1.三个组件 日志记录器 —— Logger.输出目的地 —— Appender.输出 ...
- Java学习笔记之接口和抽象类
接口(interface)1.interface创建一个接口,implements实现接口 interface jiekou{} class lie implements jiekou{}2.接口可以 ...
- OPenGL中的缓冲区对象
引自:http://blog.csdn.net/mzyang272/article/details/7655464 在许多OpenGL操作中,我们都向OpenGL发送一大块数据,例如向它传递需要处理的 ...
- Intersecting Lines POJ 1269
题目大意:给出两条直线,每个直线上的两点,求这两条直线的位置关系:共线,平行,或相交,相交输出交点. 题目思路:主要在于求交点 F0(X)=a0x+b0y+c0==0; F1(X)=a1x+b1y+c ...
- 初识Selenium(一)
Selenium入门相关PPT参考网址:http://wenku.baidu.com/view/d1e7d90390c69ec3d5bb7565.html?from=search 内容引用网址:htt ...
- eclipse Dynamic web project 工程目录
如图,我创建了一个work 的web project,当工程完成之后,部署在服务器上时,整个work工程会被打包成一个war包,如 除了可以在eclipse上运行,工具会帮我们自动部署在服务器上之外, ...