How to delete a Read-Only file
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Pierre_Comtois
Posted On:   Wednesday, October 23, 2002 08:46 AM

Here is my code : private OutputStreamWriter openFile(String fileName) throws UnsupportedEncodingException, IOException { // Stream to write file located on a web server ServletContext sc = (ServletContext) this.reqParms.get("controllerContext"); URL url = sc.getResource(fileName); OutputStream fout = new FileOutputStream(url.getFile()); OutputStream bout = new BufferedOutputStream(fout); OutputStreamWriter out = new OutputStreamWriter(bout, "8859_1"); return out; } I need to set the target file writable if it is RO or as an alternative delete   More>>


Here is my code :

			

private OutputStreamWriter openFile(String fileName)
throws UnsupportedEncodingException, IOException {


// Stream to write file located on a web server

ServletContext sc = (ServletContext) this.reqParms.get("controllerContext");

URL url = sc.getResource(fileName);

OutputStream fout = new FileOutputStream(url.getFile());

OutputStream bout = new BufferedOutputStream(fout);

OutputStreamWriter out = new OutputStreamWriter(bout, "8859_1");

return out;

}



I need to set the target file writable if it is RO or as an alternative delete and re-create the file. I can find any method to delete irregardless of file property nor how to make a ReadOnly file writable.

Can someone help/give ideas ? Thx ! Pierre    <<Less

Re: How to delete a Read-Only file

Posted By:   Brian_Glodde  
Posted On:   Wednesday, October 23, 2002 10:05 AM

In short, there isn't one. There are several issues surrounding this operation, addressed in Sun's bug database.


[quoted from developer.sun.com]

In the absence of a way to make an existing file writable, you can always delete the read-only file and rewrite a new, writable version. This is what many
source-code-control systems do anyway.


You'll have to resort to your alternative!

About | Sitemap | Contact