• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exception after ApacheCommons FileUtils.moveFile

 
Lawrence Gatson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am using ApacheCommons "FileUtils.moveFile (<file>, <file>) to move an XML file to a destination directory...

The call to "MOVE" seems to be working; however for each call to move the file I'm getting an IOException thrown with the following message...

Failed to delete original file 'C:\Temp\sourceDir\print\<filename>' after copy to 'C:\TEMP\destinationPolicy\<filename>

Does anybody have any idea why this is happening and how to prevent the exception?

Thanks
lg
 
Joe Ess
Bartender
Posts: 9256
9
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The most common cause of such a problem is that you have the file open somewhere else in the code, which prevents it from being deleted.
 
Lawrence Gatson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting, however nowhere in the code do I explicitly call file.open().

However, before the call to "move", I need to parse the XML file to determine the correct destination; I do this by creating a DOM object to read the needed data.

Could this DOM object be holding on to the files somehow? I'm not aware of a need to "close" a DOM object, should I? Also, the move call is working, it copies the file to the destination directory AND removes it from the source directory. Unfortunately it also throws the IOException.

Some additional info...my code runs inside of a thread that wakes up every TBD seconds (currently set to 20), reads the contents of a source directory and moves all files to different destination directories. I don't see how this could be causing the IOException.

Thanks for your response.

lg
 
Joe Ess
Bartender
Posts: 9256
9
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lawrence Gatson wrote:
Could this DOM object be holding on to the files somehow?


That sounds suspicious. What DOM API are you using?
 
Lawrence Gatson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not sure, how can i tell?

I'm using Java 1.6, my import list is:

import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic