fork download
  1. import java.io.BufferedReader;
  2. import java.io.BufferedWriter;
  3. import java.io.File;
  4. import java.io.FileWriter;
  5. import java.io.IOException;
  6. import java.io.InputStream;
  7. import java.io.OutputStream;
  8. import java.io.PrintStream;
  9. import java.net.URL;
  10. import org.jsoup.Connection;
  11. import org.jsoup.nodes.Document;
  12. import org.jsoup.nodes.Element;
  13.  
  14. public class Core
  15. {
  16. private static String IMAGE_DESTINATION_FOLDER = ;
  17.  
  18. public static class pathFile { public pathFile() {}
  19.  
  20. public static void mainWrite() { try { File file = new File("path.txt");
  21. file.createNewFile();
  22. FileWriter fw = new FileWriter(file);
  23. if ((Core.Bundle.getPath() != null) && (Core.Bundle.getPath() != "")) {
  24. bw.write(Core.Bundle.getPath());
  25. bw.flush();
  26. bw.close();
  27. reading.setRead(Core.Bundle.getPath());
  28. }
  29. System.out.println(file.createNewFile());
  30. } catch (IOException e) {
  31. e.printStackTrace();
  32. }
  33. }
  34.  
  35. public static void mainRead() {
  36. try {
  37. File file = new File("path.txt");
  38. file.createNewFile();
  39. java.io.FileReader fr = new java.io.FileReader(file);
  40. String read; if ((read = br.readLine()) != null) {
  41. Core.Bundle.setPath(read);
  42. System.out.println(read);
  43. Interface.t1.setText(read);
  44. }
  45. br.close();
  46. } catch (IOException e) {
  47. e.printStackTrace(); } }
  48.  
  49. public static class reading { public static String read;
  50.  
  51. public reading() {}
  52.  
  53. public static String getRead() { Core.pathFile.mainWrite();
  54. return read;
  55. }
  56.  
  57. public static void setRead(String reads) { read = reads; }
  58. } }
  59.  
  60. public Core() {}
  61.  
  62. public static class Bundle { public static String path1;
  63. public static String spath;
  64.  
  65. public Bundle() {}
  66.  
  67. public static String getPath() { return path1; }
  68.  
  69. public static void setPath(String path) {
  70. path1 = path;
  71. }
  72.  
  73. public static String getSPath() { return spath; }
  74.  
  75. public static void setSPath(String spath1) {
  76. spath = spath1;
  77. }
  78.  
  79. public static boolean getPage() { return page; }
  80. public static String strURL;
  81.  
  82. public static void setPage(boolean spage) { page = spage; }
  83.  
  84. public static String getStrURL(Element imageElement) {
  85. strURL = getPage() ? imageElement.attr("abs:href") : imageElement.attr("abs:src");
  86. return strURL; }
  87.  
  88. public static boolean page; }
  89.  
  90. public static void makeFolder(String lines, int i) { String path = lines.substring(lines.lastIndexOf("/") + 1);
  91. String[] pathf = path.split(".html");
  92. String spath = pathf[0];
  93. System.out.println("1");
  94. Bundle.setSPath(spath);
  95. System.out.println("2");
  96. File theDir = new File(Bundle.getPath() + "/" + spath);
  97. System.out.println("3");
  98. if (!theDir.exists()) {
  99. System.out.println("creating directory: " + theDir.getName());
  100. boolean result = false;
  101. try {
  102. theDir.mkdir();
  103. result = true;
  104. }
  105. catch (SecurityException localSecurityException) {}
  106. if (result)
  107. System.out.println("DIR created");
  108. }
  109. }
  110.  
  111. public static void mainSoup(String strURL) throws IOException, InterruptedException {
  112. System.setProperty("http.agent", "Mozilla/5.0");
  113. Document document = org.jsoup.Jsoup.connect(strURL).timeout(100000).get();
  114. org.jsoup.select.Elements imageElements = null;
  115. if (Bundle.getPage() == true) {
  116. imageElements = document.select("a[href$=.gif], a[href$=.jpg], a[href$=.png], a[href$=.bmp], a[href$=.webm]");
  117. } else if (!Bundle.getPage()) {
  118. imageElements = document.select("img");
  119. }
  120. for (Element imageElement : imageElements) {
  121. String strImageURL = Bundle.getStrURL(imageElement);
  122. downloadImage(strImageURL);
  123. }
  124. }
  125.  
  126. private static void downloadImage(String strImageURL) { String strImageName = strImageURL.substring(strImageURL.lastIndexOf("/") + 1);
  127. System.out.println("Saving: " + strImageName + ", from: " + strImageURL);
  128. try {
  129. URL urlImage = new URL(strImageURL);
  130. InputStream in = urlImage.openStream();
  131. byte[] buffer = new byte['က'];
  132. int n = -1;
  133. OutputStream os = new java.io.FileOutputStream(IMAGE_DESTINATION_FOLDER + "/" + Bundle.getSPath() + "/" + strImageName);
  134. while ((n = in.read(buffer)) != -1) {
  135. os.write(buffer, 0, n);
  136. }
  137. os.close();
  138. System.out.println("Image saved");
  139. } catch (IOException e) {
  140. e.printStackTrace();
  141. }
  142. }
  143. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:16: error: illegal start of expression
  private static String IMAGE_DESTINATION_FOLDER = ;
                                                   ^
1 error
stdout
Standard output is empty