MCPcopy Index your code
hub / github.com/OpenSourcePhysics/osp / run

Method run

src/test/ReleaseZipFileTest.java:57–101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55 chooser.showOpenDialog(frame, new Runnable() {
56
57 @Override
58 public void run() {
59 File file = chooser.getSelectedFile();
60 String path = file.getAbsolutePath();
61 if (!path.endsWith(".trz"))
62 return;
63 System.out.println("TRZ path " + path);
64
65 OSPRuntime.setPreference("file_chooser_directory", file.getParent());
66 OSPRuntime.savePreferences();
67
68 Map<String, ZipEntry> map = ResourceLoader.getZipContents(path, false);
69
70 for (String next : map.keySet()) {
71 if (next.contains(".htm")) {
72 System.out.println("zip entry: " + next);
73 URL url0 = null;
74 Resource res = null;
75 try {
76 url0 = new URL("jar", null, new URL("file", null, path + "!/" + next).toString()); //$NON-NLS-1$ //$NON-NLS-2$
77 res = new Resource(url0);
78 } catch (MalformedURLException e) {
79 }
80
81 if (res != null)
82 try {
83 URL url = res.getURL();
84// see https://bugs.openjdk.java.net/browse/JDK-8239054?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel
85 InputStream stream = getInputStreamNoCache1(url);
86// also works:
87// //InputStream stream = getInputStreamNoCache2(url);
88 stream.close();
89 } catch (Exception e) {
90 System.err.println(e);
91 }
92
93 try {
94 Files.delete(file.toPath());
95 } catch (Exception e) {
96 System.err.println(e);
97 }
98 System.out.println("file deleted? " + !file.exists());
99 }
100 }
101 }
102
103 }, null);
104 }

Callers

nothing calls this directly

Calls 12

setPreferenceMethod · 0.95
savePreferencesMethod · 0.95
getZipContentsMethod · 0.95
getURLMethod · 0.95
existsMethod · 0.80
printlnMethod · 0.65
getParentMethod · 0.65
containsMethod · 0.65
closeMethod · 0.65
getAbsolutePathMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected