Search in sources :

Example 1 with FileUploadException

use of uk.ac.bris.cs.rfideasalreadytaken.lumberjack.exceptions.FileUploadException in project lumberjack by fn-ctional.

the class WebBackend method multipartFileToRecords.

private Iterable<CSVRecord> multipartFileToRecords(MultipartFile csv) throws FileUploadException {
    try {
        File file = new File(csv.getOriginalFilename());
        csv.transferTo(file);
        Reader in = new FileReader(file);
        Iterable<CSVRecord> records = CSVFormat.DEFAULT.withHeader(HEADERS).withFirstRecordAsHeader().parse(in);
        return records;
    } catch (IOException e) {
        throw new FileUploadException();
    }
}
Also used : Reader(java.io.Reader) FileReader(java.io.FileReader) FileReader(java.io.FileReader) CSVRecord(org.apache.commons.csv.CSVRecord) IOException(java.io.IOException) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) FileUploadException(uk.ac.bris.cs.rfideasalreadytaken.lumberjack.exceptions.FileUploadException)

Aggregations

File (java.io.File)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 Reader (java.io.Reader)1 CSVRecord (org.apache.commons.csv.CSVRecord)1 MultipartFile (org.springframework.web.multipart.MultipartFile)1 FileUploadException (uk.ac.bris.cs.rfideasalreadytaken.lumberjack.exceptions.FileUploadException)1