0
디렉토리를 만들려고 시도했지만 AccessDeniedException이 계속 발생합니다. 어떻게 액세스 할 수 있습니까?MacOS에서 AccessDeniedException
코드 :
String pathForMac = System.getProperty("user.home") + "Library\\Application Support\\Petatech\\Zindroid";
Path macPath = Paths.get(pathForMac);{
if (!Files.exists(macPath)) {
try {
Files.createDirectory(macPath);
} catch (Exception e) {
System.out.println(e);
JOptionPane.showMessageDialog(null, e.toString(), "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
사실 Paths.get (pathForMac), Files.exists (macPath) 및 Files.createDirectory (macPath)는 SecurityException을 throw 할 수 있습니다. 스택 추적을 확인하고 doPrivileged 블록에서 해당 문을 래핑하십시오. – Harold