Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

renameTo for Directories on Solaris

Thread view: 
ebresie@gmail.com - 11 Apr 2006 22:49 GMT
I've been attempting to rename a directory on Solaris 8 and continue to
have problems.

I read other threads that mention it is not possible to do when moving
between partitions on Solaris, but I am renaming to the same
paritition.

I am basically attempting the following:

File oldName  = new File("/opt/OldDirectoryName");
File newName = new File("/opt/NewDirectoryName");

if ( oldName.renameTo( newName ) )
 // Successfully renamed
else
 // Failed to rename

For some reason I seem to continually be unable to do this.

Any ideas?

Eric
Thomas Fritsch - 11 Apr 2006 23:46 GMT
> I am basically attempting the following:
>
[quoted text clipped - 9 lines]
>
> Any ideas?

What happens if you try it in a shell
  mv /opt/OldDirectoryName /opt/NewDirectoryName
? Do you get an error message from the shell?
I would guess, you'll get something like "permission denied", because the
operation requires write-access to the /opt directory.

Signature

"TFritsch$t-online:de".replace(':','.').replace('$','@')

JScoobyCed - 12 Apr 2006 02:43 GMT
>> if ( oldName.renameTo( newName ) )
>>  // Successfully renamed
[quoted text clipped - 10 lines]
> I would guess, you'll get something like "permission denied", because the
> operation requires write-access to the /opt directory.

It's a good suggestion, but not necessary the right thing. I got similar
problem on FreeBSD (ok, Mac OS X :) ). I could rename or move or delete
my file with the shell command line, but not from Java File.renameTo(File)
Unfortunately at that time I was in a hurry to close the project and did
"the dirty Harry way" (shame on me):
FileInputStream on the oldFile
FileOutputStream on the new file
read from old file arrays of byte[] and write them to the output.

It has the advantage of working, but in term of performances, it is
really bad. My project didn't need performance, so it was ok, but...

Signature

JSC

ebresie@gmail.com - 12 Apr 2006 17:25 GMT
Does that work for directories as well?

I'm not really up on java security configuration processes, but could
this in any way have to do with security policy for my java
environment?  

Eric
Thomas Fritsch - 12 Apr 2006 17:56 GMT
ebresie@gmail.com schrieb:

> Does that work for directories as well?
>
> I'm not really up on java security configuration processes, but could
> this in any way have to do with security policy for my java
> environment?  
If renameFile() fails because of java security, then you would get a
SecurityException. If it fails because of another reason (OS denies
permission), then you get "false" as return-value. So you can
distinguish between these causes easily.

Signature

"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')

ebresie@gmail.com - 12 Apr 2006 17:30 GMT
Yup...this seems to be the case.

I had performed the rename step in a perl script previously, which I
was attempting to duplicated in java.  The perl script was running as
root at boot time, so it did not exhibit this problem.

Eric


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.