Java FileSystem .getUserPrincipalLookupService ()
Syntax
FileSystem.getUserPrincipalLookupService() has the following syntax.
public abstract UserPrincipalLookupService getUserPrincipalLookupService()
Example
In the following code shows how to use FileSystem.getUserPrincipalLookupService() method.
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.UserPrincipalLookupService;
/*from w ww .j a va2s . c o m*/
public class Main {
public static void main(String[] args) throws IOException {
UserPrincipalLookupService lookupService = FileSystems.getDefault().getUserPrincipalLookupService();
Path path = Paths.get("c:/");
Files.setOwner(path, lookupService.lookupPrincipalByName("joe"));
}
}
The code above generates the following result.