read data from MultipartFile which has csv uploaded from browser

前端 未结 3 1867
无人及你
无人及你 2020-12-30 02:46

May be I am doing it worng by using MultipartFile upload feature.

I have to read data from csv file which will be chosen by the client through the browser. I used Mu

3条回答
  •  情深已故
    2020-12-30 03:04

    I used a buffer to read line by line and get from multipart the inputstream. Maybe is more code, but I find helpful read text file by lines.

    BufferedReader br;
    List result = new ArrayList<>();
    try {
    
         String line;
         InputStream is = multipart.getInputStream();
         br = new BufferedReader(new InputStreamReader(is));
         while ((line = br.readLine()) != null) {
              result.add(line);
         }
    
      } catch (IOException e) {
        System.err.println(e.getMessage());       
      }
    

提交回复
热议问题