[Java/File]读取日文CSV文件不乱码

try {
            StringBuilder sb=new StringBuilder();
            sb.append("
Content in File:'"+filePathname+"'
");
            BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(filePathname)), "shift_jis"));  
            String line = null;  
            int lineNo=1;
            while( ( line = br.readLine() ) != null ) {
                sb.append("Line#"+lineNo+"
");
                
                String[] arr=line.split("(^\s*")|("\s*,\s*")|("\s*$)");
                
                for(int i=1;i<arr.length;i++) {// Jump first empty string
                    sb.append("    Column:"+i+" text='"+arr[i]+"'
");
                }
                
                lineNo++;
            }
            br.close();  
            logger.info(sb.toString());
        } catch (FileNotFoundException ex) {
            logger.info("Cannot find the file:'"+filePathname+"because of the FileNotFoundException:'"+ex.getLocalizedMessage()+"'.");
        } catch (IOException ex) {
            logger.info("Cannot read the file:'"+filePathname+"because of the IOException:'"+ex.getLocalizedMessage()+"'.");
        } 

上文红字是关键.

--END-- 2019-12-03 13:20

原文地址:https://www.cnblogs.com/heyang78/p/11976040.html