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 ...
随机推荐
- 引入的ajax中异步添加联系人
申请出差控制器 中 填写联系人 直接在控制器中实例化联系人表,收集ajax提交的数据.插入表 public function addcontacts(){ $model = M('contacts') ...
- asp.net textbox控件readonly为true时,后台取值的问题
如题,在后台通过textbox.Text方式取值为空,不论你默认值是否是空,如想要获得,需通过request.Form[""]的方式.
- IOS中Label根据上个label的内容设置下个label的frame
#import "ViewController.h" @interface ViewController () @property(nonatomic,strong)UILabel ...
- http請求瀏覽器的緩存機制
轉載自:http://kb.cnblogs.com/page/73901/ 流程 当资源第一次被访问的时候,HTTP头部如下 (Request-Line) GET /a.html HTTP/1.1 H ...
- 修改apache配置文件去除thinkphp url中的index.php
例如你的原路径是 http://localhost/test/index.php/index/add那么现在的地址是 http://localhost/test/index/add如何去掉index. ...
- boost库之graph入门
#include <boost/graph/undirected_graph.hpp> #include <boost/graph/adjacency_list.hpp> us ...
- js管理内存
数据不再有用时,最好通过将其值置NULL来释放其引用-这个做法叫做解除引用(dereference).这个做法适用于全局变法和全局对象的属性. function createPerson(name){ ...
- 通过intent启动Activity
android应用程序内部通过Intent来实现Activity间的跳转.也知道通过Intent调用系统程序.但若想在应用程序A内开启应用程序B(前提是A.B均已安装),该如何去实现? 记录下实现过程 ...
- hack,不同的IE浏览器
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- UVALive 7299 Boggle(深搜的姿势)
一开始确实是我的锅,我把题意理解错了,以为是一个q周围没有q的时候才可以当时qu,其实是只要碰到q,他就是qu,所以我们也可以通过预处理的方式,把字典中的不满足qu连在一起的直接去掉. 后来的各种TI ...