• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

File Permissions

 
Author
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.!!
 
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Malhar Barai
Author
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic