What steps will reproduce the problem?
I generated a kml file with the api JavaAPIforKML version 2.2 like that :
try {
File kmlFile =files.get(TypeOfFile.kml);
kmlMaker.marshal(kmlFile);
logger.debug("The file " + kmlFile.getPath() + " has been created");
} catch (FileNotFoundException e) {
logger.error(e.getMessage());
throw new CoreServiceException("Error while the creation of KML file", e);
}
After the generation, I tried to delete the kml file with this code but it
doesn't work :
for(int i=0;i<directoryFiles.length;i++){
String filePath = directoryFiles[i].getPath();
boolean fileIsDeleted = false;
try {
FileDeleteStrategy.FORCE.delete(directoryFiles[i]);
fileIsDeleted = true;
} catch (IOException e) {
e.printStackTrace();
}
if(fileIsDeleted) logger.debug("The file " + filePath + " has been deleted");
else logger.error("The file " + filePath + " hasn't been deleted");
}
This exception is throwed : java.io.IOException: Unable to delete file:
C:\DEV\Tmp\KML\3013899924069204776\1662188016.kml
Have you some suggestions for me ? I took a look in the source code of the api
but I don't have all sources, I think the outputStream is not closed inside the
api.
You'll find below a little JUnit on this problem and you can noticed that the
delete of the file doesn't work :
@Test
public void deleteKML() throws Exception {
Kml kmlMaker = new Kml();
File kmlFile = new File("C:\\Dev\\Tmp\\KML\\TEST1-913289299.kml");
kmlMaker.marshal(kmlFile);
Assert.assertTrue(kmlFile.delete());
}
Thanks in advance for your help.
What is the expected output? What do you see instead?
After the generation of the kml file, I should be able to delete the file in
the process.
What version of the product are you using? On what operating system?
I use the version 2.2.
Original issue reported on code.google.com by ludovic....@gmail.com on 8 Aug 2014 at 4:16
Original issue reported on code.google.com by
ludovic....@gmail.com
on 8 Aug 2014 at 4:16