// Path of the downloaded File: String path = "D: \ TDDownload \ system \", fileName = "cn_windows_8_1_pro_vl_x86_dvd_291_1_iso"; file File = new File (path + fileName ); inputStream in = new FileInputStream (file); OutputStream OS = resp. getOutputStream (); // clear the data in the response cache. Only the status code and Header resp are retained. reset (); byte [] buffer = new byte [128]; long downloaded = 0; String range = req. getHeader ("range"); if (range! = Null) {downloaded = Long. parseLong (range. split ("-") [0]. split ("=") [1]); // If the 206 status is set, the resp can be downloaded from a breakpoint. setStatus (206); // sets the download range resp. setHeader ("Content-Range", "bytes" + downloaded + "-" + file. length () + "/" + file. length ();} resp. setContentType ("application/octet-stream"); // file name resp. addHeader ("Content-Disposition", "attachment; filename =" + new String (fileName. getBytes (); // file size resp. addHeader ("Content-Lengt H ", file. length () + ""); // The accept range is bytes resp. setHeader ("Accept-Ranges", "bytes"); int len = 0; while (len = in. read (buffer ))! =-1) {OS. write (buffer, 0, len);} in. close (); OS. flush (); OS. close ();