zoukankan      html  css  js  c++  java
  • [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

  • 相关阅读:
    Qt 智能指针学习(7种指针)
    Springmvc+Spring+Hibernate搭建方法
    DDD分层架构之领域实体(基础篇)
    LeetCode
    RabbitMQ
    Cocos2d-x环境搭建
    使用快捷键提升C#开发效率
    C# 6.0
    avalonjs 1.3.7发布
    VS2015安装
  • 原文地址:https://www.cnblogs.com/heyang78/p/11976040.html
Copyright © 2011-2022 走看看