/java/

Spring Boot. Uploading Files.

2015-12-29 16:09:37

public static File createFile(MultipartFile file, String filePath) throws Exception {

    File newFile = new File(filePath);

    byte[] bytes = file.getBytes();
    BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(newFile));
    stream.write(bytes);
    stream.close();

    return newFile;
}