Skip to content

Instantly share code, notes, and snippets.

@alincc
Created June 23, 2016 12:09
Show Gist options
  • Save alincc/2078107276f7b2015b2002f03fb608d4 to your computer and use it in GitHub Desktop.
Save alincc/2078107276f7b2015b2002f03fb608d4 to your computer and use it in GitHub Desktop.
Save file to folder
public class FileService {
private static final Logger logger = Logger.getLogger(FileService.class);
@Override
public boolean uploadFile(MultipartFile file, FileInfo fileInfo) {
// Find folder to save the file
String fileDir = PropertiesUtil.getProperty("file.dir");
// Create file
File f = new File(fileDir + fileInfo.getFileName());
try {
// Write to file
FileUtils.writeByteArrayToFile(f, file.getBytes());
} catch (IOException e) {
logger.error(e.getLocalizedMessage());
return false;
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment