file renaming/copying & permissions

Using JDK 1.2 File methods...

1) When you use renameTo() does it overwrite existing files?  If so will it overwrite read-only files?

2) When you use setReadOnly() is there
any way to set a file back to rw?

Thanx,
CJ
LVL 19
cheekycjAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mbormannCommented:
(1) This is checked with the default security manager if installed, I think the default checkWrite() is empty,so implement ur own SM and force the behaviour u want,be sure to override the checkWrite().
0
mbormannCommented:
oops i am hitting the submit button sooner ,been getting a bit forgetful lately.

(2) I dont think so in Pure Java,if u find it out pls lemme knwo
0
cheekycjAuthor Commented:
OK for 2) is no.

for 1) if it is not set to Read-Only then it will overwrite the file.  That is correct?

CJ
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

mbormannCommented:
for (1) I dont know for certain sure but I dont think so but u know for a Application generally u never have a SM in place ,so havea SM in place and have the desired functionality u want,that is what we do in all our subsystems.
0
cheekycjAuthor Commented:
SM???
(pardon my ignorance)

CJ
0
mbormannCommented:
Security Manager
0
cheekycjAuthor Commented:
I guess I could do a 2 step renameTo()

1. if File.Exists() then File.delete()
// deletes the file that would be overwritten.
2. File.renameTo();

If you issue a delete command on a ReadOnly file... does it give an error?

CJ
0
mbormannCommented:
CJ ,
I tried it on NT4.0 jdk1.1.5

>>>>>If you issue a delete command on a ReadOnly file... does it give an error?
I deleted the read only file

>>>>>When you use renameTo() does it overwrite existing files?  If so will it overwrite read-only files?

Yes
0
cheekycjAuthor Commented:
Thanx for all the help.  Post as answer and I will give you the points.

CJ
0
mbormannCommented:
so what r u going to do finally?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cheekycjAuthor Commented:
I am going to use Unix to do my Security management... give ownership of the application to root but let anyone execute it (so no one can delete any of the config/app files)

Then in the app I am using a 2 step saving mechanism (for files just in case the app crashes)
I save the latest config to a temp.
rename the current config to .bak.
rename the temp to the current.

This way if the app crashes I still have either a temp or a .bak still in place.

Thanx for the help.
CJ
0
mbormannCommented:
CJ, u have deleted ur Memory Issues question?

why didnt u leave a comment at that b4 deleting?
0
cheekycjAuthor Commented:
No, I haven't deleted it but it dissapeared???  I couldn't find it. I wanted to distribute points.  I found out our final problem was being caused by a Bean called Formula1.

How do I get my question back or find it?

CJ
0
mbormannCommented:
Oohs now I remember abt 2 weesk ago suddenly i got 4000 points and one of my pending questions also got deleted ,as it was small fry i let it go.

But u gotta tell the guys at the EE Csutomer service and make ti reappear.

sorry for not remembering this as I wanted to refer to it today for 1 of the URL's for IOStreams

Cheers
;-)
0
mbormannCommented:
Ok the URL is
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=10235790 

I think that they didnt follow their own practice of pending deleted question notification ,ask them all abt it or see my pending question in my ShowUser/Information on .....

bye
0
cheekycjAuthor Commented:
I will post a question at EE's Customer Service.. I don't remember the Question Number but maybe they can dig it up.

CJ
0
cheekycjAuthor Commented:
I never deleted the question .. and it was an active question so I don't know why they would.  I posted a question in the EE Customer Service area and hopefully they can revive our discussion.

CJ
0
mbormannCommented:
I gave the URL in above post,
hoep it helps u.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.