我已经尝试了.txt
,.sql
,.java
的以下成功,但我不能用.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());
}
正在使用Windows 7(64位)上的spring MVC开发项目。
也许Windows上运行了一个不寻常的防病毒软件或类似的安全产品?
如果是这样,请禁用防病毒软件或将其配置为允许这些文件类型。
只要它被启用,它实际上正在通过阻止这些文件写入来完成它应该做的事情。