Use existing utility method.
This also avoids the weird old structure that closed an auto-closed input stream inside the try-with-resources block.
This commit is contained in:
@@ -50,23 +50,17 @@ public class FileUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
// as a last resort, try copying the old data over the new
|
// as a last resort, try copying the old data over the new
|
||||||
try (FileInputStream fin = new FileInputStream(source);
|
try {
|
||||||
FileOutputStream fout = new FileOutputStream(dest)) {
|
copy(source, dest);
|
||||||
|
|
||||||
StreamUtil.copy(fin, fout);
|
|
||||||
|
|
||||||
// close the input stream now so we can delete 'source'
|
|
||||||
fin.close();
|
|
||||||
if (!deleteHarder(source)) {
|
|
||||||
log.warning("Failed to delete " + source +
|
|
||||||
" after brute force copy to " + dest + ".");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
log.warning("Failed to copy " + source + " to " + dest + ": " + ioe);
|
log.warning("Failed to copy " + source + " to " + dest + ": " + ioe);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!deleteHarder(source)) {
|
||||||
|
log.warning("Failed to delete " + source + " after brute force copy to " + dest + ".");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user