@ Override public void setOwner ( Path p , String username , String groupname ) throws IOException { if ( username == null && groupname == null ) { throw new IOException ( "username == null && groupname == null" ) ; } if ( username == null ) { execCommand ( pathToFile ( p ) , Shell . SET_GROUP_COMMAND , groupname ) ; } else { //OWNER[:[GROUP]] String s = username + ( groupname == null ? "" : ":" + groupname ) ; execCommand ( pathToFile ( p ) , Shell . SET_OWNER_COMMAND , s ) ; } }
Use the command chown to set owner .