8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: CopyUtils.java,v 1.3 2008/09/22 20:49:28 kevinserwin Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copies file from source to destination.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The destination directories will be created if it is not in the system
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param sourceFile The source file object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param destFile The destination file object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param overwrite The flat to indicate whether to overwrite.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param preserveLastModified The flat to preserve modified date
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static void copyFile(File sourceFile, File destFile,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster boolean overwrite, boolean preserveLastModified) throws IOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster copyFile(sourceFile, destFile, null, overwrite, preserveLastModified);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copies file from source to destination.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The destination directories will be created if it is not in the system
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param sourceFile The source file object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param destFile The destination file object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param tokens The map to replace the file contents.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param overwrite The flat to indicate whether to overwrite.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param preserveLastModified The flat to preserve modified date
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static void copyFile(File sourceFile, File destFile,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Properties tokens, boolean overwrite, boolean preserveLastModified)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster (destFile.lastModified() < sourceFile.lastModified())) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Enumeration tokensName = tokens.propertyNames();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String name = (String) tokensName.nextElement();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster while ((count = in.read(buffer, 0, buffer.length)) != -1) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster destFile.setLastModified(sourceFile.lastModified());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copies file from source to destination.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The destination directories will be created if it is not in the system
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param in The input stream object..
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param destFile The destination file object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param overwrite The flat to indicate whether to overwrite.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static void copyFileFromJar(InputStream in, File destFile,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster while ((count = in.read(buffer, 0, buffer.length)) != -1) {