有下述代码,从文件中读取数据转换成char保存到字符串中。
.........
byte abyte0[] = new byte[16];
try
{
stream.readFully(abyte0);
}
catch(EOFException eofexception)
{
throw new JDBFException("Unexpected end of file reached.");
}
//这个时候前10个字节是(intel小尾方式):0xD0F2BAC5(中文字符“序号”的16进制值).
StringBuffer stringbuffer = new StringBuffer(10);
for(int i = 0; i < 10; i++)
{
if(abyte0[i] == 0)
break;
//到这个时候转换成了如:0xD0变为\ufffd0...等。。输出就是一些乱码?请问怎样把他变为可见的中文字符。
stringbuffer.append((char)abyte0[i]);
}
......
.........
byte abyte0[] = new byte[16];
try
{
stream.readFully(abyte0);
}
catch(EOFException eofexception)
{
throw new JDBFException("Unexpected end of file reached.");
}
//这个时候前10个字节是(intel小尾方式):0xD0F2BAC5(中文字符“序号”的16进制值).
StringBuffer stringbuffer = new StringBuffer(10);
for(int i = 0; i < 10; i++)
{
if(abyte0[i] == 0)
break;
//到这个时候转换成了如:0xD0变为\ufffd0...等。。输出就是一些乱码?请问怎样把他变为可见的中文字符。
stringbuffer.append((char)abyte0[i]);
}
......
stream = new DataInputStream(inputstream);
StringBuffer stringbuffer = new StringBuffer(10);
stringbuffer.append(new String(abyte0));
StringBuffer stringbuffer = new StringBuffer(10);
for(int i = 0; i < 10; i++)
{
if(abyte0[i] == 0)
break;
stringbuffer.append((char)abyte0[i]);
}