usually, I use property to rw data stead of database when it's simply.
but I offen run into an other trouble: hell of charset about chinese.
in fact, it's not only trouble about chinese, some espically character are so on. such as ' '(space), \n, \r, \t, <, >, ... etc.
there is 2 solution I found as below:
approach 1:
save your properties file as utf-8, utf-8 is a good solution for cross-platform & multi-language, but don't forget read it by utf-8 too.
It's error demo, it will get some chaos code stead chinese what you want
InputStream stream=new FileInputStream("demo.properties");
Property p=new Property;
p.load(stream)
the correct demo
InputStream stream=new FileInputStream("demo.properties");
InputStreamReader reader=new InputStreamReader(stream, "utf-8");
Property p=new Property;
p.load(reader)
approach 2:
though approach above are solved issue of chinese, but it not word about especial code (' ', \t, \r, \n, etc.)
so here is an other solution:
native2ascii
it's a exe in jdk\bin path. it mean: native code to ascii
cmd format:
native2ascii -encoding [charset] inputfile outputfile
sample:
native2ascii -encoding utf-8 a.properties b.properties
compile a file(saved as utf-8 before) to b(will save as ansi)
native2ascii -encoding gbk a.properties b.properties
compile a file(saved as ansi but chinese code by gbk before) to b(will save as ansi)
it's word as below:
convert all especial character of inputfile into of unicode(\uxxxx) outputfile,
and save outputfile as ansi format, so we can use it without indicate any charset. property will auto get the especial character with unicode.
InputStream stream=new FileInputStream("demo.properties");
Property p=new Property;
p.load(stream)
分享到:
相关推荐
note-R&S_Password_Removed.pdf
三星Note Pro 12.2&Tab Pro 12.2平板上手.docx
1. final变量的细节特征: 1. Java核心类库就提供了很多不可变类: 因此可以放心使用 2. 如何设计自定义的不可变类呢 3. 可变类型数据成
A Note about 《C++ 并发编程实战》
SAP Note & OSS introduction
java notejava notejava notejava notejava notejava notejava note
HTML&CSS note
死亡笔记New Tab Extension使您的Chrome浏览器焕然一新。...如果您喜欢Death Note扩展程序,建议您看看我们的其他扩展程序。 您可以通过访问www.choosetab.com来获得这些扩展名。 支持语言:English
华为Note10手机原厂维修图纸 原理图 电路图 元件图 手机故障维修图 华为Note10 位置图 位号图 元件图.exe 华为Note10 原理图 电路图.exe 华为Note10 注释图 故障标注 主板元器件位置图.exe 华为Note10 原厂图 维修...
NoteExpress参考文献管理软件简要教程 一.什么是NoteExpress 参考文献管理软件 二.NoteExpress软件安装 三.建立自己第一个NoteExpress 数据库 四.以参考文献为中心的个人知识管理 五. 研究时心得的记录---笔记...
some table about note manage
黑群无更新NoteStation后显示一直加载,通过安装会旧版本可解决。 最近套件中心提示NoteStation要升级(版本 2.6.0-1407)升级完成后打开NoteStation一直显示 “正在加载” ,不过数据是都在的。 二、解决办法 1、...
红米Note4驱动是小米官方提供的红米note4手机usb的驱动程序,很多用户的手机初次连接到电脑的时候总是会提供未知设备接入,其实这就是驱动没安装的缘故,这里给大家提供的这款驱动可以解决手机连电脑的时候出现的...
title: 'Vue.js路由报错:TypeError: Cannot read property ''_c'' of undefined'错误详情:像上面这
In this note it is proved that the above property is unavailable unless alpha = 1 or a = 0. Moreover, a new equality on E-alpha (at(alpha)) is developed, whose limit state as alpha up
st7796s 详细手册和application note, 应用笔记有配不同玻璃,该芯片驱动不同接口的初始化代码
红米note10pro谷歌相机
红米note移动版手机USB驱动程序是一款可以有效解决红米note移动版手机无法正常连接电脑的驱动工具,本站提供了红米note移动版手机USB驱动下载地址,有需要的朋友们可以前来下载使用。 本驱动是小米最新产品红米note...
解锁后刷入 红米Note7|lineage18.1| 安卓11.0|顶级流畅|唯美清新|全新手势|强力推荐