读的时候必须进行转换!
public static String GB2Unicode(String s) {
if(s == null)
{
return s;
}
char[] orig = s.toCharArray();
byte[] dest = new byte[orig.length];
for (int i=0;i<orig.length;i++)
dest[i] = (byte)(orig[i]&0xFF);
try
{
ByteToCharConverter toChar = ByteToCharConverter.getConverter("GBK");
return new String(toChar.convertAll(dest));
}
catch (Exception e)
{
System.out.println(e);
return s;
}
}
ResourceBundle rb = ResourceBundle.getBundle("hello");
String title = GB2Unicode(rb.getString("hello.title"));
public static String GB2Unicode(String s) {
if(s == null)
{
return s;
}
char[] orig = s.toCharArray();
byte[] dest = new byte[orig.length];
for (int i=0;i<orig.length;i++)
dest[i] = (byte)(orig[i]&0xFF);
try
{
ByteToCharConverter toChar = ByteToCharConverter.getConverter("GBK");
return new String(toChar.convertAll(dest));
}
catch (Exception e)
{
System.out.println(e);
return s;
}
}
ResourceBundle rb = ResourceBundle.getBundle("hello");
String title = GB2Unicode(rb.getString("hello.title"));
请在“ 感谢xmvigour(微电)”中留言
小弟有赠分