FileAccessPermissions implements Cloneable { @Override public String toString() { String result = Integer.toString(this.maskBits, 8); int len = result.length(); if (len == 1) { result = "000" + result; } else if (len == 2) { result = "00" + result; } else if (len == 3) { result = "0" + result; } return result; } FileAccessPermissions();  FileAccessPermissions(int mask); static FileAccessPermissions createByUmask(int umask, boolean isDirectory); int getMaskBits(); void setMaskBits(int mask); boolean isReadable(FileAccessClass fileModeClass); void setReadable(boolean readable); void setReadable(FileAccessClass fileModeClass, boolean readable); boolean isWritable(FileAccessClass fileModeClass); void setWritable(boolean writable); void setWritable(FileAccessClass fileModeClass, boolean writable); boolean isExecutable(FileAccessClass fileModeClass); void setExecutable(boolean executable); void setExecutable(FileAccessClass fileModeClass, boolean executable); boolean isSetuid(); void setSetuid(boolean setuid); boolean isSetgid(); void setSetgid(boolean setgid); boolean isSticky(); void setSticky(boolean sticky); void chmod(String chmod); @Override int hashCode(); @Override boolean equals(Object obj); @Override FileAccessPermissions clone(); @Override String toString(); static final int MASK_READABLE; static final int MASK_WRITABLE; static final int MASK_EXECUTABLE; static final int MASK_SETUID; static final int MASK_SETGID; static final int MASK_STICKY; }
@Test public void testToString() { assertEquals("0001", new FileAccessPermissions(01).toString()); assertEquals("0123", new FileAccessPermissions(0123).toString()); assertEquals("7777", new FileAccessPermissions(07777).toString()); }