在读取txt文件时,可能会遇到中文乱码情况,解决办法如下:
private String getTextString(String pathandname) throws IOException{
String str="";
FileInputStream fis = new FileInputStream(pathandname);
// InputStreamReader isr=new InputStreamReader(fis, "gbk");
// BufferedReader br=new BufferedReader(isr);
int size=fis.available();
byte[] buffer=new byte[size];
fis.read(buffer);
fis.close();
str = new String(buffer,"GBK");//支持双字节字符
myApp.setCharNumofString(str.length());//存储总字符数
return str;
}