Parse CSV file uploaded as MultipartFile using Apache Commons CSV

Last Updated on

From MultiPartFile to Reader object

The parse method only accepts a single java.io.Reader object and you may need to convert the MultipartFile object to a Reader object. The MultipartFile class has the getInputStream() whose return value can be passed to the constructor of the ImputStreamReader class. The an object of type ImputStreadReader is passed to the parse method.

A multipart resolver is required to make this work. Place the following codes in you @Configuration class.


Karl San Gabriel

Professional Software Developer