• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

exception after ApacheCommons FileUtils.moveFile

 
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
 
Bartender
Posts: 9615
16
Mac OS X Linux 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: 9615
16
Mac OS X Linux 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;
 
    Bookmark Topic Watch Topic
  • New Topic