I need something to get the hard link count from a file in solaris10 os in java.
parsing ls -l is not an option.
I tried using posix for java http://bmsi.com/java/posix/index.html but could not get it working.
Is there any other easy API or code to get this information?
In Java 7, you can use the new file attribute API to get it with java.nio.file.Files.getAttribute(path, "unix:nlink").
java.nio.file.Files.getAttribute(path, "unix:nlink")
"unix" API ( "posix" nlink), Oracle/OpenJDK. , createLink Files. .
createLink
Files
JNI stat/lstat C, ls:
stat
lstat
stat --format=%h filename
.
, -ascii. , , , ( - ).
Also consider using jnr-posix stat (2) implementation for this.