File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes File Permissions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "File Permissions" Watch "File Permissions" New topic
Author

File Permissions

Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
hi all
i want to set file permission on a file on my server. Its a Linux server. I tried with following :
FilePermission fp = new FilePermission("filename.txt","read,write");
but its giving errors...
any idea.!!
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
hi,
The reason for getting error is valid. Because you can set on permssion at a time. since you have passed ""read,write" which is wrong, you should either pass read or write.
read- gives no option to edit but only view the content
Write - gives read + modifiy permission
.your objective can be achived by just give write permission.
NOTE wrong place to post this question.
-arun


Sharing is learning
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
Originally posted by Arun Boraiah:
hi,
The reason for getting error is valid. Because you can set on permssion at a time. since you have passed ""read,write" which is wrong, you should either pass read or write.
read- gives no option to edit but only view the content
Write - gives read + modifiy permission
.your objective can be achived by just give write permission.

NOTE wrong place to post this question.

dear i have done it through servlets, so i posted in this forum, & still the giving only one permission doesnt help still.
More info. my servlets r running on Apache.
thanx anyway..
malhar
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
hi,
let me know what is the error message displayed. And also can you tell what is your perpose of file permission(i.e, what is that not able achive by giving write permission).
-arun
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
Originally posted by Arun Boraiah:
hi,
let me know what is the error message displayed.

And also can you tell what is your perpose of file permission(i.e, what is that not able achive by giving write permission).

dear
i m uploading a file & for the filename to remain unique, i want to rename it with user id, i.e it appears as userid-file.extension, but i m not able to rename it on server, as i dont hv permission to change it. it successfully executed on "localhost", without the filepermission settings.
hope i m clear.
malhar
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
Hi,
After reading the uploaded file use following code
File f = new File("Uploaded.file");
// give whatever name you need
FileOutputStream fos = new FileOutputStream(f);
fos.write(b); // write byte
Hope this will come handy.
-arun
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
Originally posted by Arun Boraiah:
Hi,
After reading the uploaded file use following code
File f = new File("Uploaded.file");
// give whatever name you need
FileOutputStream fos = new FileOutputStream(f);
fos.write(b); // write byte
Hope this will come handy.
-arun

dear
can u plz elaborate on this. bcoz this will leave a copy of the original file on the server n make a new file with diff. name.
malhar
[ February 12, 2002: Message edited by: malhar barai ]
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
hi,
There is no need to create a file and then rename. When you are creating the file itself give the name you wish.
-arun
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File Permissions