Get file's mime type by path
30 December 2014
Load properties file to beans in spring mvc
In Java 7 you can now just use Files.probeContentType(path)
eg:
try {
String mimeType = Files.probeContentType(FileSystems.getDefault().getPath(filePath+fileName));
response.setContentType(mimeType);
IOUtils.copy(inputStream, response.getOutputStream());
} finally {
IOUtils.closeQuietly(inputStream);
}
blog comments powered by Disqus