Guest User

Untitled

a guest
Jan 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. private void startTask(Label st, ListView<String> view, HashMap<String, String> hash)
  2. {
  3.  
  4. Platform.runLater(new Runnable() {
  5. @Override
  6. public void run() {
  7. runTask(st,view,hash);
  8. }
  9. });
  10. }
  11.  
  12. private void runTask(Label st, ListView<String> view, HashMap<String, String> hash){
  13. String link = hash.get(view.getSelectionModel().getSelectedItem());
  14. File file = new File("temp.zip");
  15. try {
  16. FileUtils.copyURLToFile(new URL(link), file);
  17. byte[] buffer = new byte[1024];
  18. ZipInputStream zis = new ZipInputStream(new FileInputStream(file));
  19. ZipEntry zipEntry = zis.getNextEntry();
  20. File newFile;
  21. FileOutputStream fos;
  22. String fileName;
  23. while(zipEntry != null){
  24.  
  25. fileName = zipEntry.getName();
  26. if(fileName.contains("##TEMP##")) continue;
  27. if(fileName.contains("MACOSX")) continue;
  28. newFile = new File(fileName);
  29. fos = new FileOutputStream(newFile);
  30. int len;
  31. while ((len = zis.read(buffer)) > 0) {
  32. fos.write(buffer, 0, len);
  33. }
  34. fos.close();
  35. zipEntry = zis.getNextEntry();
  36. }
  37. zis.closeEntry();
  38. zis.close();
  39. } catch (IOException | NullPointerException e) {
  40. e.printStackTrace();
  41. }
  42. st.setText("Status: Ready");
  43.  
  44.  
  45. }
Add Comment
Please, Sign In to add comment