You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jef Sullivan <je...@ikano.com> on 2005/12/12 23:27:16 UTC

Moving a file

Forgive the double posting on this message, if it occurs. 

I need help with some code..
I want to move a file (CVS) to another folder.
The code that I am using is this.

File file = new File("Summary_" + dateVar + ".csv");
File dir = new File(propStuff.getProperty("recordDir"));	// value is
written C:\\Workspace\\Reports\\

boolean success = file.renameTo(new File(dir, file.getName()));
If (!success) {
	// Error text
}

This keeps producing an error. The code is consistent on several websites
that I have found when googling 
on java: move a file. Any suggestions on how to get this working?




Jef


RE: Moving a file

Posted by Jef Sullivan <je...@ikano.com>.
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.




Jef 

> -----Original Message-----
> From: Jef Sullivan [mailto:jefs@ikano.com] 
> Sent: Monday, December 12, 2005 3:27 PM
> To: 'Tomcat Users List'
> Cc: users@tomcat.apache.org
> Subject: Moving a file
> 
> Forgive the double posting on this message, if it occurs. 
> 
> I need help with some code..
> I want to move a file (CVS) to another folder.
> The code that I am using is this.
> 
> File file = new File("Summary_" + dateVar + ".csv");
> File dir = new File(propStuff.getProperty("recordDir"));	
> // value is
> written C:\\Workspace\\Reports\\
> 
> boolean success = file.renameTo(new File(dir, 
> file.getName())); If (!success) {
> 	// Error text
> }
> 
> This keeps producing an error. The code is consistent on 
> several websites that I have found when googling on java: 
> move a file. Any suggestions on how to get this working?
> 
> 
> 
> 
> Jef
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org