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 / June 2006

Tip: Looking for answers? Try searching our database.

Java RenameTo()

Thread view: 
vurdalak@hotmail.it - 27 Jun 2006 16:05 GMT
Devo leggere un file e spostarlo in una cartella secondaria dopo di che
cancellarlo dalla principale.
Ho constato che i file li apro senza problemi e li leggo.
Il mio problema consiste che ogni tanto non riesco a spostare i file...
come se fossero bloccati eppure io li chiudo...

C'è un modo x chiudere i file anche se qualche utente li tiene aperti
e spostarli?

// Qui carico il file e lo sposto
File fp = new File(readFolder + listDir[i]);
fp.renameTo(new File(writeFolder + listDir[i]));
rhino_moderate@yahoo.ca - 27 Jun 2006 17:05 GMT
> Devo leggere un file e spostarlo in una cartella secondaria dopo di che
> cancellarlo dalla principale.
[quoted text clipped - 8 lines]
> File fp = new File(readFolder + listDir[i]);
> fp.renameTo(new File(writeFolder + listDir[i]));

There may be a few Italian-speakers on this newsgroup - I'm not one of
them! - but most of us use English.

If you know English, you will get more answers if you ask your question
in English.

If you don't know English, I'm pretty sure there is an Italian-language
Java newsgroup that would be more helpful. Of course, if you don't know
English, you'll have trouble understanding my remarks ;-)

--
Rhino
EdwardH - 27 Jun 2006 18:39 GMT
Si señor!
Vurdalak - 28 Jun 2006 09:45 GMT
Sorry...

I must move one file in from a folder... but sometimes i move it but
sometimes i can't do it...

I use RenameTo()...

The problem can be that the file is open or used by another user...
My question is:
Can i close all connection to the my file and move it everytime?

This is my code:

File fp = new File(readFolder + listDir[i]);
fp.renameTo(new File(writeFolder + listDir[i]));

Tanks
Oliver Wong - 28 Jun 2006 21:23 GMT
> Sorry...
>
[quoted text clipped - 11 lines]
> File fp = new File(readFolder + listDir[i]);
> fp.renameTo(new File(writeFolder + listDir[i]));

   If the file is opened by another user, you probably can't force a
"disconnection" for those other users without the permission of the OS. As
far as I know, there's no API within Java itself to request that all other
users of a file get disconnected.

   The renameTo method returns a boolean, which is true if the renaming
succeeded and false if it did not.

   - Oliver


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.