Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How can we get file Inode info using java?  RSS feed

 
Murty Akundi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am reading a log file "xyz.log" using java program while non java application writing log entries to "xyz.log".
Non java application archives the log file once it reaches certain size limit also. For example it archives "xyz.log" to xyz.log.0" and creates new a file "xyz.log"
So my question is How can we find whether the file has renamed or not using java?
FYI in C we can use stat method to get inode to find out this info.
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Until now, I personally have not seen any class in the java.io package that provides such information as the inode.

I do not know if such thing as inode exists in all operating systems. I realized of the concept until I started working with Linux.

However, if you have C library with the code to get the information and if it happens to be correct that the JDK does not offer any class to provide such platform specific information, maybe you could use JNI (Java Native Interface) to reuse your C code and extract the inode of the file.

Of course, your application would stop being portable, but I guess that would be something you wouldn't mind if the inode is realy a POSIX OS issue.

Regards,
Edwin Dalorzo
 
Murty Akundi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Edwin.
I could not find any class/method available to get inode information in java.I will write c program rather than using native methods from java.


regards
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good luck then, comrade!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!