Is there a way to pull User, Group , Other permissions of a file


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Is there a way to pull User, Group , Other permissions of a file

  1. #1
    Join Date
    Feb 2007
    Posts
    1

    Is there a way to pull User, Group , Other permissions of a file

    I wanted to know whether Java provides any API to pull up each and every permission associated with a file.

    For example: In Unix, a file has 3 sets of permissions as shown below:

    <UserPermissions><GroupPermissions><Others'Permissions>

    Example: -rwxrwxrwx

    r - for read
    w - for write
    x - for execute

    There are some methods provided in java.io.File, such as canRead() and canWrite(), which help in telling whether a file is readable or writable. But I did not find any API which tells whether a perticular user has read/write/execute permission or not. Also, I presume the canRead(),canWrite() methods pull up the permissions pertaining to the owner of the file, but not for the group and others part of a Unix File's permissions.

    Is there a way to pull up the read/write/executable permissions for all the 3 catergories namely, UserPermissions, GroupPermissions and Others'Permissions.

    I appreciate your note on this and appreciate your time too.

  2. #2
    Join Date
    Dec 2006
    Location
    Kerala,India
    Posts
    51
    No, canRead(),canWrite() methods check whether the application can read or write. It doesn't check whether the owner has any permission. I mean these methods check whether the user from which JVM is running has the permission to read or write permission to tha file.
    At present there is no API which returns all three sets of permission of a file.

Similar Threads

  1. VB.net Windows user group
    By shers in forum .NET
    Replies: 1
    Last Post: 10-23-2005, 04:31 AM
  2. Replies: 0
    Last Post: 12-10-2002, 03:27 PM
  3. How to use Java to lock a file
    By Cynthia Leslie in forum Java
    Replies: 3
    Last Post: 06-09-2001, 06:43 PM
  4. file name==class name. why?
    By siva in forum Java
    Replies: 2
    Last Post: 01-03-2001, 10:40 AM
  5. NT user group with Java code
    By sam in forum Java
    Replies: 1
    Last Post: 07-25-2000, 05:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center