MultipartFile转File

public File transferMultipartFileToFile(MultipartFile file) {
        File toFile = null;

        try {
            toFile = File.createTempFile(Objects.requireNonNull(file.getOriginalFilename()),null);
            file.transferTo(toFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return toFile;
    }

 

你可能感兴趣的:(大厂任性挑,JAVA,MultipartFile,File)