Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void startTask(Label st, ListView<String> view, HashMap<String, String> hash)
- {
- Platform.runLater(new Runnable() {
- @Override
- public void run() {
- runTask(st,view,hash);
- }
- });
- }
- private void runTask(Label st, ListView<String> view, HashMap<String, String> hash){
- String link = hash.get(view.getSelectionModel().getSelectedItem());
- File file = new File("temp.zip");
- try {
- FileUtils.copyURLToFile(new URL(link), file);
- byte[] buffer = new byte[1024];
- ZipInputStream zis = new ZipInputStream(new FileInputStream(file));
- ZipEntry zipEntry = zis.getNextEntry();
- File newFile;
- FileOutputStream fos;
- String fileName;
- while(zipEntry != null){
- fileName = zipEntry.getName();
- if(fileName.contains("##TEMP##")) continue;
- if(fileName.contains("MACOSX")) continue;
- newFile = new File(fileName);
- fos = new FileOutputStream(newFile);
- int len;
- while ((len = zis.read(buffer)) > 0) {
- fos.write(buffer, 0, len);
- }
- fos.close();
- zipEntry = zis.getNextEntry();
- }
- zis.closeEntry();
- zis.close();
- } catch (IOException | NullPointerException e) {
- e.printStackTrace();
- }
- st.setText("Status: Ready");
- }
Add Comment
Please, Sign In to add comment