Stat implements Serializable, Cloneable { @Override public String toString() { String humanReadableSize = sizeToString(_size); String humanReadableMTime = LocalDateTime .ofInstant(Instant.ofEpochMilli(_mtime), ZoneId.systemDefault()) .format(LS_TIME_FORMAT); return modeToString(_mode)+" "+String.format("%4d %4d %4d %4s %s", _nlink, _owner, _group, humanReadableSize, humanReadableMTime); }  int getDev(); void setDev(int dev); int getIno(); void setIno(int ino); int getMode(); void setMode(int mode); int getNlink(); void setNlink(int nlink); int getUid(); void setUid(int owner); int getGid(); void setGid(int group); int getRdev(); void setRdev(int rdev); long getSize(); void setSize(long size); long getATime(); void setATime(long atime); long getMTime(); void setMTime(long mtime); long getCTime(); void setCTime(long ctime); long getFileId(); void setFileid(long fileid); long getGeneration(); void setGeneration(long generation); Type type(); static String modeToString(int mode); static String sizeToString(long bytes); @Override Stat clone(); @Override String toString(); boolean isDefined(StatAttribute attr); void undefine(StatAttribute attr); static final int S_TYPE; static final int S_PERMS; static final int S_IFSOCK; static final int S_IFLNK; static final int S_IFREG; static final int S_IFBLK; static final int S_IFDIR; static final int S_IFCHR; static final int S_IFIFO; }
@Test public void testToString() { Stat stat = new Stat(); stat.setNlink(7); stat.setUid(1); stat.setGid(2); stat.setSize(3L); Calendar localCal = Calendar.getInstance(); localCal.set(Calendar.YEAR, 2003); localCal.set(Calendar.DAY_OF_MONTH, 1); localCal.set(Calendar.MONTH, Calendar.FEBRUARY); localCal.set(Calendar.HOUR_OF_DAY, 14); localCal.set(Calendar.MINUTE, 15); localCal.set(Calendar.SECOND, 0); localCal.set(Calendar.MILLISECOND, 0); stat.setMTime(localCal.getTimeInMillis()); stat.setMode(0755 | Stat.S_IFDIR); assertEquals("drwxr-xr-x 7 1 2 3 Feb 01 14:15", stat.toString()); stat.setMode(0401 | Stat.S_IFREG); stat.setNlink(6666); stat.setSize(1024*16); localCal.set(Calendar.DAY_OF_MONTH, 29); localCal.set(Calendar.HOUR_OF_DAY, 1); stat.setMTime(localCal.getTimeInMillis()); assertEquals("-r-------x 6666 1 2 16K Mar 01 01:15", stat.toString()); stat.setMode(0070 | Stat.S_IFLNK); stat.setSize(1024*1024*1024*1024L - 1); assertEquals("l---rwx--- 6666 1 2 1024G Mar 01 01:15", stat.toString()); }