public static void loadTxt(InputStream is) {
List<Bill2> billList = new ArrayList<>();
try {
//这个arrStrings内容就是乱码的
InputStreamReader isr = new InputStreamReader(is,"UTF-8");
System.out.println( Charset.defaultCharset().name());
BufferedReader br = new BufferedReader(isr);
String lineTxt = null; // 读取文件的方法
while ((lineTxt = br.readLine()) != null){
String[] arrStrings = lineTxt.split("|"); // 用于把一个字符串分割成字符串数组
Bill2 bill = new Bill2();
bill.setDistributionChannel(arrStrings[0]);
bill.setPlatform(arrStrings[1]);
bill.setCustomerName(arrStrings[2]);
bill.setRegulaAccount(arrStrings[3]);
bill.setTransactionDate(arrStrings[4]);
bill.setWithdrawalAmount(arrStrings[5]);
bill.setRealinterestRate(arrStrings[6]);
bill.setInterest(arrStrings[7]);
bill.setCoreSerialNumber(arrStrings[8]);
bill.setTransactionType(arrStrings[9]);
billList.add(bill); // 用set方法将取值分别添加到对应字符串数组 ,用add方法存入list
System.out.println(billList);
}
} catch (IOException e) {
e.printStackTrace();
}
}