!752 static boolean actualCopy = true; static int maxCopy = 1024*1024*1024; p { File dest = new File("/home/stefan/Downloads/Brilliance.mp4"); //print(bytesToHex(firstBytesOfFile(dest, 10))); int downloaded = (int) dest.length(); print("Existing: " + downloaded); URL url = new URL("http://cdl37.convert2mp3.net/download.php?id=youtube_pvcsa2ZesZY&key=bV7xjw9SuB4X&d=y"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestProperty("Range", "bytes=" + downloaded + "-"); InputStream in = connection.getInputStream(); try { print("Length: " + connection.getContentLength()); int status = connection.getResponseCode(); print("Code: " + status); if (status != HttpURLConnection.HTTP_PARTIAL) fail("No partial download possible!"); if (actualCopy) { FileOutputStream fos = new FileOutputStream(dest, true); // append print("Copied: " + copyStream(downloaded, downloaded+maxCopy, in, fos)); fos.close(); } else { new ByteArrayOutputStream bos; print("Tested: " + copyStream(downloaded, downloaded+10, in, bos)); byte[] bytes = bos.toByteArray(); print(bytesToHex(subArray(bytes, 0, 10))); } } finally { in.close(); } } static long copyStream(int downloaded, long maxDownload, InputStream in, OutputStream out) ctex { byte[] buf = new byte[65536]; long total = downloaded; while (total < maxDownload) { int n = in.read(buf); if (n <= 0) return total; out.write(buf, 0, n); total += n; print("Downloaded: " + toK(total) + " K"); } ret total; } static byte[] subArray(byte[] b, int start, int end) { byte[] x = new byte[end-start]; System.arraycopy(b, start, x, 0, end-start); ret x; }