String osName = System.getProperty("os.name");
                        if (!file.renameTo(newDestFile)) {
                            if (osName.toLowerCase().indexOf("windows") > -1 && newDestFile.exists()) {
                                //first remove the destFile
                                if (! newDestFile.delete()) {
                                    throw new CoreException(
                                        "Unable to remove dest file on windows: " +  newDestFile.getAbsolutePath());
                                }
                                if (!file.renameTo(newDestFile)) {
                                    throw new CoreException(
                                        "Unable to move file to dest file on windows: " + file + ", "
                                        + newDestFile.getAbsolutePath());
                                }
                            } else {
                                throw new CoreException(
                                    "Unable to move file to dest file: " + file + ", " + newDestFile.getAbsolutePath());
                            }
                        }
                } finally {
                    lock.release();
                    channel.close();
                }
            }
        } catch (IOException e) {
            System.err.println("IOException: " + e.getMessage());
            e.printStackTrace(System.err);
            throw new CoreException("Unable to rename file: " + e.getMessage(), e);
        }
    }