fork download
  1. public static void downloadFiles(String strURL, String strPath, int buffSize) {
  2. try {
  3. URL connection = new URL(strURL);
  4. urlconn = (HttpURLConnection) connection.openConnection();
  5. urlconn.setRequestMethod("GET");
  6. urlconn.connect();
  7. InputStream in = null;
  8. in = urlconn.getInputStream();
  9. OutputStream writer = new FileOutputStream(strPath);
  10. byte buffer[] = new byte[buffSize];
  11. int c = in.read(buffer);
  12. while (c > 0) {
  13. writer.write(buffer, 0, c);
  14. c = in.read(buffer);
  15. }
  16. writer.flush();
  17. writer.close();
  18. in.close();
  19. } catch (IOException e) {
  20. System.out.println(e);
  21. }
  22.  
  23. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class, interface, or enum expected
	public static void downloadFiles(String strURL, String strPath, int buffSize) {
	              ^
Main.java:4: error: class, interface, or enum expected
            HttpURLConnection urlconn;
            ^
Main.java:5: error: class, interface, or enum expected
            urlconn = (HttpURLConnection) connection.openConnection();
            ^
Main.java:6: error: class, interface, or enum expected
            urlconn.setRequestMethod("GET");
            ^
Main.java:7: error: class, interface, or enum expected
            urlconn.connect();
            ^
Main.java:8: error: class, interface, or enum expected
            InputStream in = null;
            ^
Main.java:9: error: class, interface, or enum expected
            in = urlconn.getInputStream();
            ^
Main.java:10: error: class, interface, or enum expected
            OutputStream writer = new FileOutputStream(strPath);
            ^
Main.java:11: error: class, interface, or enum expected
            byte buffer[] = new byte[buffSize];
            ^
Main.java:12: error: class, interface, or enum expected
            int c = in.read(buffer);
            ^
Main.java:13: error: class, interface, or enum expected
            while (c > 0) {
            ^
Main.java:15: error: class, interface, or enum expected
                c = in.read(buffer);
                ^
Main.java:16: error: class, interface, or enum expected
            }
            ^
Main.java:18: error: class, interface, or enum expected
            writer.close();
            ^
Main.java:19: error: class, interface, or enum expected
            in.close();
            ^
Main.java:20: error: class, interface, or enum expected
        } catch (IOException e) {
        ^
Main.java:22: error: class, interface, or enum expected
        }
        ^
17 errors
stdout
Standard output is empty