Я использую API-интерфейс Java 7. Я написал класс, отлично работающий над созданием каталогов Ubuntu, но когда я запускаю тот же код в Windows, он бросает ошибку:
Exception in thread "main" java.lang.UnsupportedOperationException: 'posix:permissions' not supported as initial attribute
at sun.nio.fs.WindowsSecurityDescriptor.fromAttribute(Unknown Source)
at sun.nio.fs.WindowsFileSystemProvider.createDirectory(Unknown Source)
at java.nio.file.Files.createDirectory(Unknown Source)
at java.nio.file.Files.createAndCheckIsDirectory(Unknown Source)
at java.nio.file.Files.createDirectories(Unknown Source)
at com.cloudspoke.folder_permission.Folder.createFolder(Folder.java:27)
at com.cloudspoke.folder_permission.Main.main(Main.java:139)
Код класса My Folder
package com.cloudspoke.folder_permission;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.UserPrincipal;
import java.util.Set;
public class Folder{
// attributes required for creating a Folder
private UserPrincipal owner;
private Path folder_name;
private FileAttribute<Set<PosixFilePermission>> attr;
public Folder(UserPrincipal owner,Path folder_name,FileAttribute<Set<PosixFilePermission>> attr){
this.owner=owner;
this.folder_name=folder_name;
this.attr=attr;
}
//invoking this method will create folders
public void createFolder(){
try {
//createDirectories function is used for overwriting existing folder instead of createDirectory() method
Files.createDirectories(folder_name, attr);
Files.setOwner(folder_name, owner);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("created Folder "+this.folder_name);
}
}
Ошибка возникает из createFolder
метода Folder
.
Как устранить эту ошибку?