like this there are about 100 rows.
Don't bother saving the CSV as a tmp file as Spring's Mulitpart will do that for you and just insert the rows directly (the request may take longer to process but given your ostensible current knowledge you can worry about optimizing that later)
private void readWithCsvBeanReader(MultipartFile uploadedFile) throws Exception {
ICsvBeanReader beanReader = null;
try {
beanReader = new CsvBeanReader(new InputStreamReader(uploadedFile.getInputStream()),
CsvPreference.STANDARD_PREFERENCE);
// the header elements are used to map the values to the bean (names
// must match)
final String[] header = beanReader.getHeader(true);
// get Cell Processor
final CellProcessor[] processors = getProcessors();
Make your controller something like:
@RequestMapping(value = "/add", method=RequestMethod.POST)
public String upload(@RequestParam("file") MultipartFile file) throws IOException {
// call your csv parsing code.
}
Make sure you make your FORM looks something like:
<h1>Add a File for testing</h1>
<form method="post" action="/add" class="well form-vertical" enctype="multipart/form-data">
<input type="file" name="file" />
<button type="submit" class="btn">{{actionLabel}}</button>
</form>
Take notice of the enctype
For input and output you should understand Java's IO Decorator pattern.
I Recommend you keep it as simple as possible so that you can learn the basics. Then worry about adding more robust solutions/libraries.