5 import java
.util
.zip
.*;
7 import java
.awt
.event
.*;
12 public ZipData(String file
) {
15 public boolean extractEntry(String entry
, String destination
,
18 OutputStream out
= null;
19 InputStream in
= null;
21 System
.out
.println("Copying: " + entry
);
22 System
.out
.println("To: " + destination
);
24 if (statusLabel
!= null) {
25 statusLabel
.setText("Copying " + entry
);
29 if (entry
.lastIndexOf("/") != -1) {
30 entryName
= entry
.substring(entry
.lastIndexOf("/") + 1);
37 if (destination
.lastIndexOf(File
.separator
) != -1) {
38 destName
= destination
.substring(destination
.lastIndexOf(File
.separator
) + 1);
41 destName
= destination
;
44 if (!destName
.equals(entryName
))
45 destination
= destination
.concat(entryName
);
47 System
.out
.println("Unzipping " + entry
+ " to " + destination
);
50 out
= new FileOutputStream(destination
);
52 catch (IOException ioe
) {
53 System
.err
.println("Error opening " + destination
+
54 ": " + ioe
.getMessage());
56 if (statusLabel
!= null)
57 statusLabel
.setText("Error opening" + destination
+
58 "see SFramework.log for more information");
63 if (entry
.startsWith("/") == false)
66 in
= this.getClass().getResourceAsStream(entry
);
68 System
.err
.println("File " + entry
+ " not found in jar file");
70 if (statusLabel
!= null)
71 statusLabel
.setText("Failed extracting " + entry
+
72 "see SFramework.log for more information");
78 byte[] bytes
= new byte[1024];
81 while ((len
= in
.read(bytes
)) != -1)
82 out
.write(bytes
, 0, len
);
84 catch (IOException ioe
) {
85 System
.err
.println("Error writing " + destination
+ ": " +
88 if (statusLabel
!= null)
89 statusLabel
.setText("Failed writing " + destination
+
90 "see SFramework.log for more information");
98 catch (IOException ioe
) {