Created
July 24, 2018 11:56
-
-
Save Ikhiloya/d20ca3149b99d7923a49efd2b0901b9a to your computer and use it in GitHub Desktop.
A helper method to convert a Multipart File to a java.io file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * A helper method to convert a Multipart File to a java.io file | |
| * | |
| * @param file a Multipart file to be converted | |
| * @return a java.io File | |
| * @throws IOException | |
| */ | |
| public static File convertMultipartFile(MultipartFile file) throws IOException { | |
| File convertedFile = new File(file.getOriginalFilename()); | |
| convertedFile.createNewFile(); | |
| FileOutputStream fos = new FileOutputStream(convertedFile); | |
| fos.write(file.getBytes()); | |
| fos.close(); | |
| return convertedFile; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is good coding for java language