Skip to content

Instantly share code, notes, and snippets.

@Ikhiloya
Created July 24, 2018 11:56
Show Gist options
  • Select an option

  • Save Ikhiloya/d20ca3149b99d7923a49efd2b0901b9a to your computer and use it in GitHub Desktop.

Select an option

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
/**
* 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;
}
@Sagormia
Copy link
Copy Markdown

It is good coding for java language

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment