### Eclipse Workspace Patch 1.0 #P org.eclipse.update.core Index: src/org/eclipse/update/internal/core/JarDeltaInstallHandler.java =================================================================== RCS file: /home/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/core/JarDeltaInstallHandler.java,v retrieving revision 1.1 diff -u -r1.1 JarDeltaInstallHandler.java --- src/org/eclipse/update/internal/core/JarDeltaInstallHandler.java 15 Nov 2005 06:01:07 -0000 1.1 +++ src/org/eclipse/update/internal/core/JarDeltaInstallHandler.java 20 Apr 2006 21:25:32 -0000 @@ -18,7 +18,6 @@ import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; -import java.nio.channels.FileChannel; import java.util.Date; import java.util.Enumeration; import java.util.jar.JarFile; @@ -90,15 +89,42 @@ newJarFile.delete(); newJarFile.createNewFile(); - - FileChannel in = new FileInputStream(tempFile).getChannel(); - FileChannel out = new FileOutputStream(newJarFile).getChannel(); - in.transferTo( 0, in.size(), out); - - in.close(); - out.close(); + + copyFile(tempFile, newJarFile); } + public static void copyFile(File src, File dst) throws IOException { + try { + NioHelper.copyFile(src, dst); + return; + } catch (IOException e) { + throw e; + } catch (NoSuchMethodError e1) { + // fall through + } catch (NoClassDefFoundError e2) { + // fall through + } catch (Exception e3) { + // fall through + } + + FileInputStream in=null; + FileOutputStream out=null; + try { + in = new FileInputStream(src); + out = new FileOutputStream(dst); + byte[] buffer = new byte[4096]; + int len; + while ((len=in.read(buffer)) != -1) { + out.write(buffer, 0, len); + } + } finally { + if (in != null) + in.close(); + if (out != null) + out.close(); + } + } + public static void addToJar(JarOutputStream jos, JarFile jf) throws IOException { Enumeration e = jf.entries(); Index: src/org/eclipse/update/internal/core/NioHelper.java =================================================================== RCS file: src/org/eclipse/update/internal/core/NioHelper.java diff -N src/org/eclipse/update/internal/core/NioHelper.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/update/internal/core/NioHelper.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.update.internal.core; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.channels.FileChannel; + + +public class NioHelper { + // This method must be in a seperate class file otherwise a NIO class not found error + // will be thrown loading the calling class. We put it in it's own class so the + // caller can catch the error/exception. + static void copyFile(File src, File dst) throws IOException { + FileChannel in = null; + FileChannel out = null; + + try { + in = new FileInputStream(src).getChannel(); + out = new FileOutputStream(dst).getChannel(); + in.transferTo( 0, in.size(), out); + } finally { + if (in != null) + in.close(); + if (out != null) + out.close(); + } + } + + +}