• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

getting a UNIX inode in java

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I go about getting the INODE of a File in Java?
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You won't be able to without some native code (i.e., C code linked in via the Java Native Interface). Java's platform-independent view of filesystems doesn't allow for anything that low-level.
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An 'ls -i' command using Runtime.exec( ) would also provide this information, but it would not be especially effecient (very bad performance actually) with an extreme amount of overhead (at least seen from the Java perspective) for such a small bit of information that you can't really do anything with in Java anyway.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I think it's a bit premature to worry about performace here. This could be an issue if you're calling the mathod many times in a tight loop, but like most "performance issues", in many actual real-life cases it's not an issue at all. Using Runtime.exec() is a relatively easy way to do this, so if Chase really needs inode info in a Java program for some reason, that's a perfectly valid thing to try. If he needs inode info on a lot of files, it may be more efficient to modify the script to handle many files with one process, e.g "ls -iR" to recursively list the subdirectories too (if that was the goal). But it's probably best to wait until there's an observable performance problem here before worrying about how best to fix it.
 
You don't like waffles? Well, do you like this tiny ad?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic