我已经成功地尝试了以下.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());
}项目正在使用Windows7 (64位)上的spring MVC进行开发。
发布于 2018-03-06 22:59:46
也许有一个不寻常的杀毒软件或类似的安全产品在你的Windows上运行?
如果是,请禁用杀毒软件或将其配置为允许这些文件类型。
只要它被启用,它实际上正在通过阻止这些文件写入来做它应该做的事情。
https://stackoverflow.com/questions/49106740
复制相似问题