Reputation: 867
I have tried the followings for .txt
, .sql
, .java
with success BUT I can't write file with the extension with .pdf
, .jpg
, .zip
.
File file = new File("d:/myFolder/something.txt");
File file = new File("d:/myFolder/something.sql");
File file = new File("d:/myFolder/something.java");
// Executed Successfully for the above 3 but java.io.FileNotFoundException (Access is denied) show for these files below.
File file = new File("d:/myFolder/something.jpg");
File file = new File("d:/myFolder/something.pdf");
File file = new File("d:/myFolder/something.zip");
try {
FileOutputStream fos = new FileOutputStream(file);
fos.write(mpf.getBytes());
fos.close();
fos.flush();
} catch (Exception e) {
System.out.println(e.getMessage());
}
Project is being developed using spring MVC on Windows 7 (64 bit).
Upvotes: 0
Views: 171
Reputation: 19675
Perhaps there is an unusual antivirus or similar security product running on your Windows?
If so, either disable the antivirus or configure it to permit these filetypes.
So long as it is enabled, it is actually doing exactly what it is supposed to do by blocking these file-writes.
Upvotes: 1