Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Retrieve owner property from file or directory  RSS feed

 
Joseph jo
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

How can i retrieve owner property from file or directory?

currently im trying to use IO and NIO libraries...but i dont know which prpperty can be used to retrieve "owner".

could anyone put some light on...im in urgent need.

Thanks in advance

-Joseph
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is this question related to JSP? Incorrectly writing raw Java code in a JSP file instead of a Java class, and having problems with that Java code doesn't make it a JSP problem.

The IO forum would have been more appropriate. Have patience and a moderator may move it sooner or later.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on JSP.

For more information, please read this.

This post has been moved to a more appropriate forum.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, Please read this for more information.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simply put: you can't do this with pure Java. The reason is that ownership of a file or directory is file system specific. FAT certainly doesn't have it, and neither does NTFS. As far as I know, it is only used in Unix file systems like EXT2/3, ReiserFS etc.

You can either use JNI to retrieve it, or call an external program like "ls" and parse its results.
 
Joseph jo
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:Simply put: you can't do this with pure Java. The reason is that ownership of a file or directory is file system specific. FAT certainly doesn't have it, and neither does NTFS. As far as I know, it is only used in Unix file systems like EXT2/3, ReiserFS etc.

You can either use JNI to retrieve it, or call an external program like "ls" and parse its results.



Hi,

I have built same application in .net too and I retrieve owner and other details of files and folders using IO, FileInfo and DirectoryInfo classes and thats on windows platform ofcourse.

So i was looking for an alternative for it.

I know for Linux/Unix I can use "posix" for retrieving these values...but im not able to find for windows.

Does Java provide any such classes to retrieve these info from files and folders?



Thanks and Regards

-Jo
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was mistaken - NTFS does indeed have an owner for files and folders. But again, FAT does not, so there still is no single way to do this for all operating systems and all file systems. Java does not have a solution for it, so my advice holds: use JNI or call an external program that can do it for you and pass its results.

For Linux / Unix you can use "ls -l", for Windows "cmd /s dir /q".
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is a step by step description by someone who did exactly this using JNI:

http://www.telio.be/blog/2007/06/26/getting-the-file-owner-in-java-using-jni/
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!