Changing a log file's attributes such as the owner property

Discussion in 'Java' started by marcwentink@hotmail.com, Apr 6, 2006.

  1. Guest

    I have been looking how to change the file attributes inside java, I
    want to make a java program that would give certain Linux rights to the
    created file. But it seems this is impossible, which is logical if you
    take into account that java should be platform independant, and
    ownership is typical a unix/linux property.

    Right?

    Nevertheless, if I try to make a log file it is only readable for the
    linux user that started the java application. And this not always the
    user that will try to read the log file. So what could I do?

    Marcus Wentink
    , Apr 6, 2006
    #1
    1. Advertising

  2. Guest

    Gordon Beaton:

    > Or use Runtime.exec() after creating the > file to invoke a linux


    Ok, that's a good idea. Thank you very much

    And if I use it like +/- this code below 'chmod' will only be used once
    every java VM machine call.

    class LogIt
    {
    private static File file;
    private static BufferedWriter out;

    static
    {
    open();
    Runtime.exec()
    }




    Marcus Wentink
    , Apr 6, 2006
    #2
    1. Advertising

  3. On 6 Apr 2006 06:19:59 -0700, wrote:
    > Nevertheless, if I try to make a log file it is only readable for the
    > linux user that started the java application. And this not always the
    > user that will try to read the log file. So what could I do?


    The default file creation mode is determined by the user's umask. If
    you want to change the default file permissions, change the umask in
    the user's shell before running the application. "man umask" will tell
    you more.

    Or use Runtime.exec() after creating the file to invoke a linux
    specific utility (chmod) to let other users read the file.

    If the file is (already) readable by members of the file's *group*,
    you might also add (specific) users to that group so they can read the
    file.

    /gordon

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
    Gordon Beaton, Apr 6, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jojo
    Replies:
    20
    Views:
    1,114
  2. Tzap
    Replies:
    1
    Views:
    898
    Joe Attardi
    Mar 1, 2006
  3. Ajay

    file owner id

    Ajay, Aug 9, 2004, in forum: Python
    Replies:
    1
    Views:
    409
    Tom B.
    Aug 9, 2004
  4. Ishmael Rufus

    NTFS File System - File Owner

    Ishmael Rufus, Jan 31, 2007, in forum: Java
    Replies:
    0
    Views:
    385
    Ishmael Rufus
    Jan 31, 2007
  5. Zarko Gajic

    Custom Attributes (AttributeTargets.Property) and Property Type

    Zarko Gajic, Apr 7, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    434
    Zarko Gajic
    Apr 7, 2005
Loading...

Share This Page