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

M

marcwentink

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
 
M

marcwentink

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
 
G

Gordon Beaton

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top