Skip to content

Instantly share code, notes, and snippets.

@prietopa
Created April 16, 2016 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prietopa/6d6f15e1c30d5bef4167d1a3a932909a to your computer and use it in GitHub Desktop.
Save prietopa/6d6f15e1c30d5bef4167d1a3a932909a to your computer and use it in GitHub Desktop.
package es.pp.jm.utils;
import java.io.FileOutputStream;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
public class DownloadVideoFromInternet {
// http://stackoverflow.com/questions/921262/how-to-download-and-save-a-file-from-internet-using-java
public static void main(String[] args) throws Exception {
URL website = new URL("http://mediasitems.cloudapp.net/ProgressiveDownload/24dc633a-4191-4036-ba54-4a0e8e594a89.mp4");
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream("25_BuenasPracticas.mp4");
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment