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_5773_The All-purpose Zero(LIS)
题目链接:hdu_5773_The All-purpose Zero 题意: 给你一串数,让你求LIS,不过这里的0可以改变为任意数 题解: 官方题解讲的很清楚 1010 The All-purpos ...
- 修改index.php 清空mylog1.txt
进入编辑php文件vim index.php(无则新建) -->进入命令行模式--输入a(append)-->进入编辑模式-->编辑好-->esc退出编辑模式-->:q! ...
- %02d
%d表示打印整型的,%2d表示把整型数据打印最低两位,%02d表示把整型数据打印最低两位,如果不足两位,用0补齐所以打印出来就是02了
- Eclipse中配置weka,以及添加算法
Eclipse中配置weka 1 找到weka的安装位置,寻找weka的压缩文件weka-src.jar,将压缩文件解压,解压出的文件夹weka-src. 2 打开Eclipse,新建Java pro ...
- size_t, ptrdiff_t, size_type, difference_type
size_t是unsigned类型,用于指明数组长度或下标,它必须是一个正数,std::size_t ptrdiff_t是signed类型,用于存放同一数组中两个指针之间的差距,它可以负数,std:: ...
- WEBROOT根目录 <%=request.getContextPath()%>
WEBROOT根目录 <%=request.getContextPath()%> == ${pageContext.request.contextPath}
- PatrolRobot(UVa1600)BFS
PatrolRobot(UVa1600)BFS 珉黻郐距 河吏蝉醉 闵棵黏言 芤她之瞌 褰上稽莨 錾傻奉 郦玫睃芩 摇摇头还没回答魏海洪就抢先回答道:呵呵你们几个别试 蚰镉氡 钬 绦可 ...
- 【转】RestQL:现代化的 API 开发方式
原文:http://tech.meituan.com/koa-restql.html RestQL:现代化的 API 开发方式 李鑫 ·2016-08-12 11:26 koa-restql 已经在 ...
- 【bfs】 poj 3984 maze 队列存储
#include <iostream> #include <stdio.h> #include <cstring> #define Max 0x7f7f7f7f u ...
- js、html中的单引号、双引号及其转义使用
js.html中的单引号.双引号及其转义使用在js中对相关字符做判断或取值的时候很多情况下都会用到这些. ------ 在一个网页中的按钮,写onclick事件的处理代码,不小心写成如下:<in ...