File tree Expand file tree Collapse file tree 1 file changed +16
-14
lines changed
API/src/main/java/org/ohnlp/backbone/api/components/xlang/python Expand file tree Collapse file tree 1 file changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -164,22 +164,24 @@ private void extractPythonResourcesIfNotExists() {
164164 env .completeExceptionally (new IllegalArgumentException ("Could not find module " + this .bundleIdentifier ));
165165 return ;
166166 }
167- ZipInputStream zis = new ZipInputStream (is );
168- // - Now actually copy the resources over
169- ZipEntry entry ;
170- while ((entry = zis .getNextEntry ()) != null ) {
171- if (entry .isDirectory ()) {
172- continue ;
173- }
174- String pathRelative = entry .getName ();
175- File pathInTmp = new File (workDir , pathRelative );
176- byte [] contents = zis .readAllBytes ();
177- try (FileOutputStream fos = new FileOutputStream (pathInTmp )) {
178- fos .write (contents );
179- fos .flush ();
167+ try (ZipInputStream zis = new ZipInputStream (is )) {
168+ // - Now actually copy the resources over
169+ ZipEntry entry ;
170+ while ((entry = zis .getNextEntry ()) != null ) {
171+ if (entry .isDirectory ()) {
172+ continue ;
173+ }
174+ File pathInTmp = new File (workDir , entry .getName ());
175+ pathInTmp .getParentFile ().mkdirs ();
176+ try (BufferedOutputStream bos = new BufferedOutputStream (new FileOutputStream (pathInTmp ))) {
177+ byte [] buffer = new byte [8192 ];
178+ int len ;
179+ while ((len = zis .read (buffer )) > 0 ) {
180+ bos .write (buffer , 0 , len );
181+ }
182+ }
180183 }
181184 }
182- zis .close ();
183185 } catch (IOException e ) {
184186 env .completeExceptionally (e );
185187 return ;
You can’t perform that action at this time.
0 commit comments