Get Hard Link Count in Java

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?

+5
source share
3 answers

In Java 7, you can use the new file attribute API to get it with java.nio.file.Files.getAttribute(path, "unix:nlink").

"unix" API ( "posix" nlink), Oracle/OpenJDK. , createLink Files. .

+8

JNI stat/lstat C, ls:

stat --format=%h filename

.

, -ascii. , , , ( - ).

+2

Also consider using jnr-posix stat (2) implementation for this.

0
source

All Articles