Here is what I ended up doing. Thanks to "_M_"  concerning the comment about
the path being incorrect. It led me to this working resolution...

// Location of existing file
File dir = new File("C:\\Workspace\\Reports\\");
// Filename
File fXLS = new File(dir, "Report_" + sdf2.format(startTime) + ".xls");
// Path where the file should be moved
File mDir = new File("C:\\Workspace\\Reports\\Archive_XLS\\");

// Move XLS file to new directory
System.out.println("Moving XLS file to Archive location.");
boolean successXLS = fileXLS.renameTo(new File(mDir, fileXLS.getName()));
if (!successXLS) {
        // File was not successfully moved
        System.out.println("WARNING: XLS File was not moved to archive
folder.");
}
else{
        System.out.println("File " + fileXLS + " Has been moved.");
}


The differences between the resolution and what I found in the web are:

1. The fXLS includes the path to the file where the example did not. It just
had the filename.
2. The renameTo() has the location where the file is to be moved as the
first variable. The web example had the location where the file was already
located.


Thanks to everyone for their help and direction.




Jef

> -----Original Message-----
> From: MW Janssen [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, December 13, 2005 1:13 PM
> To: 'Tomcat Users List'; 'Martin Gainty'
> Subject: RE: Moving a file
> 
> try creating new file at the new location and the delete the old file.
> 
> File myFile1 = new File(filename);
> File myFile2 = new File(newpath+filename); boolean succes = 
> myFile1.renameTo(myFile2); if(success){
>       myFile1.delete();
> }
> 
> suc6
> 
> Maarten
> 
> -----Oorspronkelijk bericht-----
> Van: Martin Gainty [mailto:[EMAIL PROTECTED]
> Verzonden: dinsdag 13 december 2005 20:53
> Aan: Tomcat Users List
> Onderwerp: Re: Moving a file
> 
> Jef et al
> Have you tried the URL Spec e.g 
> file://folder/subfolder/filename for URL file specs see 
> http://archive.ncsa.uiuc.edu/SDG/Software/Mosaic/Demo/url-primer.html
> Anyone else ?
> M-
>  
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: "Tomcat Users List" <users@tomcat.apache.org>
> Sent: Tuesday, December 13, 2005 1:18 PM
> Subject: RE: Moving a file
> 
> 
> >> -------- Original Message --------
> >> Subject: RE: Moving a file
> >> From: "Jef Sullivan" <[EMAIL PROTECTED]>
> >> Date: Tue, December 13, 2005 10:17 am
> >> To: "'Tomcat Users List'" <users@tomcat.apache.org>
> >> 
> >> Additionally,
> >> The error that I am getting is the file does not exist. 
> >> Yet, the file does exists. I have verified its location, and the 
> >> spelling of the path and filename. Everything matches 
> including the 
> >> case sensitivity.
> > 
> > Your code example doesn't provide a path to the original file.  You 
> > probably need that.  Try using a full path or a path 
> relative to the 
> > default dir TC is looking in (I think it's $INSTALLDIR/bin on Linux 
> > installs).
> > 
> > _M_
> > 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.371 / Virus Database: 267.13.13/198 - Release 
> Date: 12-12-2005
>  
> 
> -- 
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.371 / Virus Database: 267.13.13/198 - Release 
> Date: 12-12-2005
>  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to