Guest User

Untitled

a guest
Sep 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. OutputStream outStream = null;
  2. InputStream is = null;
  3. HttpURLConnection conn;
  4. try {
  5. URL url;
  6. byte[] buf;
  7. int byteRead, byteWritten = 0;
  8. url = new URL(getFinalLocation("https://cdn-1.watchenga.tv/movies/the-cabin-in-the-woods/original_360.mp4"));
  9. outStream = new BufferedOutputStream(new FileOutputStream("test.mp4"));
  10.  
  11. conn = (HttpURLConnection) url.openConnection();
  12. is = conn.getInputStream();
  13. buf = new byte[1024];
  14. while ((byteRead = is.read(buf)) != -1) {
  15. outStream.write(buf, 0, byteRead);
  16. byteWritten += byteRead;
  17. }
  18. } catch (Exception e) {
  19. e.printStackTrace();
  20. } finally {
  21.  
  22. // is.close();
  23. // outStream.close();
  24.  
  25. }
Add Comment
Please, Sign In to add comment