Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: File Permissions?

  1. #1
    Member
    Join Date
    Jun 2011
    Posts
    182
    My Mood
    Where
    Thanks
    15
    Thanked 8 Times in 8 Posts

    Default File Permissions?

    I realize most OS platforms have their own system of permissions for programs accessing files... but, is there really no way at all to program into an application ways to request permissions?

    How do all of the everyday apps we use on our computers get permission? Surely there must be some way to control that....


  2. #2
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: File Permissions?

    File permissions are granted by the OS. A program requests permission by attempting an operation.

    Not quite sure what you're getting at...

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: File Permissions?

    way ... to program into an application ways to request permissions
    Who does the program ask permission of?
    See the SecurityManager class.

  4. #4
    Member
    Join Date
    Jun 2011
    Posts
    182
    My Mood
    Where
    Thanks
    15
    Thanked 8 Times in 8 Posts

    Default Re: File Permissions?

    The OS I suppose. Trying to write a file to the user's working directory. Is this even possible to do?

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: File Permissions?

    You request by trying, you get the answer by success or an exception.

  6. #6
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: File Permissions?

    Quote Originally Posted by bgroenks96 View Post
    Trying to write a file to the user's working directory. Is this even possible to do?
    Why not try it and see for yourself? - it would be far quicker than posting to a forum and waiting for an answer that has no guarantee of being correct.

    Be aware that Java applets are a special case, operating in a restrictive sandbox that doesn't permit read/writes except to/from the host server (unless permission is explicitly granted).

  7. #7
    Member
    Join Date
    Jun 2011
    Posts
    182
    My Mood
    Where
    Thanks
    15
    Thanked 8 Times in 8 Posts

    Default Re: File Permissions?

    Quote Originally Posted by dlorde View Post
    Why not try it and see for yourself? - it would be far quicker than posting to a forum and waiting for an answer that has no guarantee of being correct.

    Be aware that Java applets are a special case, operating in a restrictive sandbox that doesn't permit read/writes except to/from the host server (unless permission is explicitly granted).
    I did try it and I couldn't. That's why I posted here.

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: File Permissions?

    program into an application ways to request permissions
    This could be a security problem. What if the operator does NOT want a program to do something and sets the permissions not to allow that to be done? The program should NOT be allowed to change the operator's settings by itself.
    I did try it and I couldn't
    What the program could do when it can't do something (ie gets an exception), is ask the operator to make the permission changes needed and restart the program or allow the program to continue after the operator has granted it permission.

  9. #9
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: File Permissions?

    Quote Originally Posted by bgroenks96 View Post
    I did try it and I couldn't. That's why I posted here.
    Works fine for me - unless I try using an applet to do it. Without some more information, such as the code and the context, it's hard to say why you're having trouble. Did you get any exceptions? Did you try running the Java Console to track errors?

Similar Threads

  1. Replies: 10
    Last Post: January 12th, 2011, 05:48 AM
  2. insert(embed) a file object (.txt file) in MS excel sheet using java.
    By jyoti.dce in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 12th, 2010, 08:16 AM
  3. Permissions?
    By Vindicator in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 16th, 2010, 05:14 PM
  4. Replies: 8
    Last Post: January 6th, 2010, 09:59 AM