Lines 18-24
Link Here
|
18 |
import java.io.InputStream; |
18 |
import java.io.InputStream; |
19 |
import java.net.URI; |
19 |
import java.net.URI; |
20 |
import java.net.URISyntaxException; |
20 |
import java.net.URISyntaxException; |
21 |
import java.nio.channels.FileChannel; |
|
|
22 |
import java.util.Date; |
21 |
import java.util.Date; |
23 |
import java.util.Enumeration; |
22 |
import java.util.Enumeration; |
24 |
import java.util.jar.JarFile; |
23 |
import java.util.jar.JarFile; |
Lines 90-104
Link Here
|
90 |
newJarFile.delete(); |
89 |
newJarFile.delete(); |
91 |
|
90 |
|
92 |
newJarFile.createNewFile(); |
91 |
newJarFile.createNewFile(); |
93 |
|
92 |
|
94 |
FileChannel in = new FileInputStream(tempFile).getChannel(); |
93 |
copyFile(tempFile, newJarFile); |
95 |
FileChannel out = new FileOutputStream(newJarFile).getChannel(); |
|
|
96 |
in.transferTo( 0, in.size(), out); |
97 |
|
98 |
in.close(); |
99 |
out.close(); |
100 |
} |
94 |
} |
101 |
|
95 |
|
|
|
96 |
static boolean useNioCopy = true; |
97 |
public static void copyFile(File src, File dst) throws IOException { |
98 |
if (useNioCopy) { |
99 |
try { |
100 |
NioHelper.copyFile(src, dst); |
101 |
return; |
102 |
} catch (IOException e) { |
103 |
throw e; |
104 |
} catch (NoSuchMethodError e1) { |
105 |
// fall through |
106 |
} catch (NoClassDefFoundError e2) { |
107 |
// fall through |
108 |
} catch (Exception e3) { |
109 |
// fall through |
110 |
} |
111 |
useNioCopy = false; |
112 |
} |
113 |
|
114 |
FileInputStream in=null; |
115 |
FileOutputStream out=null; |
116 |
try { |
117 |
in = new FileInputStream(src); |
118 |
out = new FileOutputStream(dst); |
119 |
byte[] buffer = new byte[4096]; |
120 |
int len; |
121 |
while ((len=in.read(buffer)) != -1) { |
122 |
out.write(buffer, 0, len); |
123 |
} |
124 |
} finally { |
125 |
if (in != null) |
126 |
in.close(); |
127 |
if (out != null) |
128 |
out.close(); |
129 |
} |
130 |
} |
131 |
|
102 |
public static void addToJar(JarOutputStream jos, JarFile jf) throws IOException { |
132 |
public static void addToJar(JarOutputStream jos, JarFile jf) throws IOException { |
103 |
Enumeration e = jf.entries(); |
133 |
Enumeration e = jf.entries(); |
104 |
|
134 |
|