How to do chown or chgrp

L

loial

What is the best way to run the unix chown and chgrp commands in Java?

I only need to run these commands on one file at at time.
 
A

Arne Vajhøj

What is the best way to run the unix chown and chgrp commands in Java?

I only need to run these commands on one file at at time.

Runtime exec or the newer ProcessBuilder.

Arne
 
R

Roedy Green

What is the best way to run the unix chown and chgrp commands in Java?

I only need to run these commands on one file at at time.

see http://mindprod.com/jgloss/exec.html

If you need speed, you will want to write some JNI or find a JNI
library that already does what you want.

http://mindprod.com/jgloss/jni.html
--
Roedy Green Canadian Mind Products http://mindprod.com
The first 90% of the code accounts for the first 90% of the development time.
The remaining 10% of the code accounts for the other 90% of the development
time.
~ Tom Cargill Ninety-ninety Law
 
A

Arne Vajhøj

Surely the 'Java' way (in 1.7 at least) is

java.nio.file.Files.setPosixFilePermissions

As owner and group are not in PosixFilePermission
then surely not.

But it is close.

Files getFileAttributeView with PosixFileAttributeView will
provide setOwner and set Group for a programmatic solution.

Arne

PS: There is also Files setOwner but as it has no setGroup, then I
would go for the other.
 
R

Roedy Green

Ah yes, setPosixFilePermissions would be chmod.

How about Files.setOwner ?
--
Roedy Green Canadian Mind Products http://mindprod.com
The first 90% of the code accounts for the first 90% of the development time.
The remaining 10% of the code accounts for the other 90% of the development
time.
~ Tom Cargill Ninety-ninety Law
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top