在Windows 7上使用Java的某些特定文件类型拒绝访问

问题描述 投票:0回答:1

我已经尝试了.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开发项目。

java windows-7-x64
1个回答
1
投票

也许Windows上运行了一个不寻常的防病毒软件或类似的安全产品?

如果是这样,请禁用防病毒软件或将其配置为允许这些文件类型。

只要它被启用,它实际上正在通过阻止这些文件写入来完成它应该做的事情。

© www.soinside.com 2019 - 2024. All rights reserved.