成人AV在线无码|婷婷五月激情色,|伊人加勒比二三四区|国产一区激情都市|亚洲AV无码电影|日av韩av无码|天堂在线亚洲Av|无码一区二区影院|成人无码毛片AV|超碰在线看中文字幕

Java逐行讀取txt文本如何解決中文亂碼?

網(wǎng)友解答: 解決方案是: 1.要統(tǒng)一編碼,java工程的編碼,txt文本編碼,java工程中的java文本編碼都統(tǒng)一為utf-8; 2.利用 InputStreamReader(new

網(wǎng)友解答:

解決方案是:

1.要統(tǒng)一編碼,java工程的編碼,txt文本編碼,java工程中的java文本編碼都統(tǒng)一為utf-8;

2.利用 InputStreamReader(new FileInputStream(fileUrl), "utf-8")將文本再次設(shè)置為utf-8

InputStreamReader isr;

try {

isr = new InputStreamReader(new FileInputStream(fileUrl), "utf-8");

BufferedReader read = new BufferedReader(isr);

String s=null;

List<String list = new ArrayList<String();

while((s=read.readLine())!=null)

{

//System.out.println(s);

if(s.trim().length()1){

list.add(s.trim());

}

}

System.out.println("OK!");

} catch (UnsupportedEncodingException e) {

e.printStackTrace();

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

網(wǎng)友解答:

BOM 前三個字符 基本可以區(qū)分UTF-8和GBK了

標簽: