求解,写入csv文件怎么做


转瞬即逝的微笑0
浏览 1250回答 1
1回答

啊哼

public static void addCloumn(List<String> pList, String filePath) throws IOException{  BufferedReader bufReader = new BufferedReader(new FileReader(filePath));  String lineStr = "";  int rowNumber = 0;  StringBuffer nContent = new StringBuffer();  while((lineStr = bufReader.readLine()) != null){   String addValue = "";   if(rowNumber < pList.size()){    addValue = pList.get(rowNumber);   }   if(lineStr.endsWith(",")){    nContent.append(lineStr).append("\""+addValue+"\"");   }else{    nContent.append(lineStr).append(",\""+addValue+"\"");   }   rowNumber++;   nContent.append("\r\n");  }  bufReader.close();    FileOutputStream fileOs = new FileOutputStream(new File(filePath), false);  fileOs.write(nContent.toString().getBytes());  fileOs.close(); }
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java