 | 请教Android中文乱码问题 ... by 机器人 ... 29 月 9 天前 ... 1617 次点击
fis = new FileInputStream(file);
? ?? ?? ?? ?//字节数组声明定义
? ?? ?? ?? ?b = new byte[1024];
? ?? ?? ?? ?//读取文件内容放入字节数组
? ?? ?? ?? ?fis.read(b);
? ?? ?? ?? ?//把字节数组转换成字符串
? ?? ?? ?? ?Text_of_output = new String(b);? ?? ?? ?? ?
? ?? ?? ?? ?//显示读取的文件内容
? ?? ?? ?? ?et.setText(Text_of_output);
这样子在读我adb push的.txt文件(有中文)时,里面的中文读出来是乱码,这是怎么一回事呢,应该怎样解决哎呀?
Android的中文乱码问题搞得我好头痛呀,请大侠帮忙~~
我改成用FileReader读文件流也乱码,
fr = new FileReader(file);
? ?? ?? ???BufferedReader br = new BufferedReader (fr);
? ?? ?? ?? ?String s = new String("GB2312");
? ?? ?? ?? ?while ((s = br.readLine() )!=null) {
? ?? ?? ?? ?? ?? ? et.setText(s);
? ?? ?? ?? ?? ? }
烦呀 | |