can anyone tell me how to setOwner as well as the fileKey for the particular file........
i've retrieved the metadata information but can't able to set values.....
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.AclFileAttributeView;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.UserPrincipal;
/**
*
* @author user
*/
public class check1 {
public static void main(String args[]) throws IOException
{
Path file = Paths.get("C:\\clock.avi");
/*try
{
UserPrincipal owner = file.getFileSystem().getUserPrincipalLookupService().lookupPrincipalByName("sally");
Files.setOwner(file, owner);
}catch(SecurityException e){}
*/
BasicFileAttributes attr = Files.readAttributes(file, BasicFileAttributes.class);
AclFileAttributeView view = Files.getFileAttributeView(file, AclFileAttributeView.class);
//PosixFileAttributes attrs = Files.getFileAttributeView(file, PosixFileAttributeView.class).readAttributes();
//System.out.println(attrs.owner());
System.out.println("creationTime: " + attr.creationTime());
System.out.println("owner: " + view.getOwner());
System.out.println("lastAccessTime: " + attr.lastAccessTime());
System.out.println("lastModifiedTime: " + attr.lastModifiedTime());
System.out.println("isDirectory: " + attr.isDirectory());
System.out.println("isOther: " + attr.isOther());
System.out.println("isRegularFile: " + attr.isRegularFile());
System.out.println("isSymbolicLink: " + attr.isSymbolicLink());
System.out.println("size: " + attr.size());
System.out.println("fileKey: " + attr.fileKey());
}
}