try { StringBuilder sb=new StringBuilder(); sb.append("\nContent in File:'"+filePathname+"'\n"); 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+"\n"); 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]+"'\n"); } 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