Open BaseRegister opened 9 years ago
i can not replicate this on my system. i wrote a junit test:
@Test
public void test() throws Exception {
File source = new File("/tmp/fake.gz");
assertTrue(source.createNewFile());
Compressor compressor = CompressorFactory.createCompressor(source);
try {
compressor.decompress(source, new File(source.getParent()));
} catch (Exception e) {
assertTrue(source.exists());
assertTrue(source.delete());
assertFalse(new File("/tmp/fake.gz").exists());
}
}
and it runs through properly.
can you specify what environment you working are in?
Thank you for your quick response. I've done more testing and still receive the same error. Maybe it is a problem with the Java version?
Operating System: Windows 7 Java Version: 1.6.0_29 Environment: From Eclipse Luna as a java application. Also tested from Windows command prompt after creating an executable jar.
I've simplified the execution to this:
public static void main(String[] args){
File f = new File("document.txt.gz");
System.out.println("Java Version: "+ System.getProperty("java.version"));
try{
Compressor compressor = CompressorFactory.createCompressor(f);
compressor.decompress(f, new File(f.getParent()) );
}catch(IllegalArgumentException e){
e.printStackTrace();
}catch (Exception e) {
e.printStackTrace();
}finally{
System.out.println(f.delete());
}
}
Simple and clean API but I have an issue.
I am using a test file named fileNane.gz. It is not a compressed file but a text file with the .gz extension. This file seems to be locked by a process when trying to delete.
compressor.decompress(f, new File(f.getParent()) ) throws an exception as expected but I cannot delete the file.
Here is my code: