iso8859-1:单字节编码,只能表示0-255的字符范围,主要在英文上应用。
GBK:包括简体中文和繁体中文, 双字节编码。
GB2312:只包含简体中文,双字节编码。
unicode:? java使用的就是此编码; 此编码不兼容iso8859-1。
UTF: 每个字符的长度从1-6个字节不等。
System.getProperties(); //取出的为系统信息,是关于系统信息的键值对
System.getProperty("file.encoding")) ;
// 获取当前系统编码
File f = new File("D:" + File.separator + "test.txt") ;
// 实例化File类
OutputStream out = new FileOutputStream(f) ;
// 实例化输出流
byte b[] = "你好!".getBytes("ISO8859-1") ;
// 转码操作,
//最好修改为:byte b[] = "你好,".getBytes(System.getProperty("file.encoding"));
out.write(b) ;
// 保存
out.close() ;
// 关闭
本文转自 tianya23 51CTO博客,原文链接:http://blog.51cto.com/tianya23/244680,如需转载请自行联系原作者