I am trying to read a Japanese content CSV file which is downloaded and extracted pragmatically.
Code to read the CSV
String splitBy = ",";
BufferedReader br;// = new BufferedReader(new FileReader(pathOfExcel + "\\KEN_ALL.CSV "));
br = new BufferedReader(new InputStreamReader(new FileInputStream(pathOfExcel + "\\KEN_ALL1.CSV"),"SHIFT-JIS"));
String line = "";
int cnt = 0;
while((line = br.readLine()) != null){
//System.out.println("Count :: " + cnt++);
List<Object> excelList = new ArrayList<Object>();
if(line != null){
String[] splitCells = line.split(splitBy);
excelList.add(splitCells[0].replace("\"", ""));
excelList.add(splitCells[1].replace("\"", ""));
excelList.add(splitCells[2].replace("\"", ""));
excelList.add(splitCells[3].replace("\"", ""));
excelList.add(splitCells[4].replace("\"", ""));
excelList.add(splitCells[5].replace("\"", ""));
excelList.add(splitCells[6].replace("\"", ""));
excelList.add(splitCells[7].replace("\"", ""));
excelList.add(splitCells[8].replace("\"", ""));
returnList.add(excelList);
}
}
br.close();
I have tried both UTF-8 and SHIFT-JIS as shown in the following code.
br = new BufferedReader(new InputStreamReader(new FileInputStream(pathOfExcel + "\\KEN_ALL1.CSV"),"UTF-8"));
When I was trying to encode with UTF-8 and SHIFT-JIS the " excelList.add(splitCells[3].replace("\"", ""));"
will be returning the following outputs. But where as the original output should be ホッカイドウ
UTF-8 - ί¶²ÄÞ³
Shift-JIS - テ篠ッツカツイテ�楪ウ