pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


java_file2inodenum
Posted by Anonymous on Thu 18th Jan 2024 00:41
raw | new post

  1. /*
  2.  * java_file2inodenum - return dev/inode number
  3.  */
  4. import java.nio.file.*;
  5. import java.nio.file.attribute.*;
  6.  
  7. public class java_file2inodenum
  8. {
  9.         public static void main(String[] args) throws Exception {
  10.                 BasicFileAttributes attr = null;
  11.                 Path path = Paths.get("/etc/profile");
  12.  
  13.                 attr = Files.readAttributes(path, BasicFileAttributes.class);
  14.  
  15.                 Object fileKey = attr.fileKey();
  16.                 String s = fileKey.toString();
  17.                 System.out.println("key: '" + s + "'");
  18.                 String dev = s.substring(s.indexOf("dev=") + 4, s.indexOf(","));
  19.                 String inode = s.substring(s.indexOf("ino=") + 4, s.indexOf(")"));
  20.                 System.out.println("dev: " + dev);
  21.                 System.out.println("Inode: " + inode);
  22.         }
  23. }

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at