Copy kode kodenya sebagai berikut:
URL kamu = URL baru("http://localhost:8080/first/he.txt");
HttpURLConnection conn = (HttpURLConnection) ur.openConnection();//URL.openConnection() -- >return URLCommection (subkelas langsung HttpURLConnection)
conn.setRequestProperty("Range", "bytes=5-");//Atur atribut parameter permintaan dan atur pengunduhan agar dimulai dari byte ke-5;
InputStream di = samb.getInputStream();
int len = 0;
byte[] buf = byte baru[1024];
FileOutputStream keluar = FileOutputStream baru("d://a.txt");
while ((len = masuk.baca(buf)) > 0) {
keluar.tulis(buf, 0, len);
}
melampirkan();
keluar.dekat();