Skip to content

Instantly share code, notes, and snippets.

@trinhpham
Created September 10, 2021 07:07
Show Gist options
  • Save trinhpham/ba5bac01b4465b49ade2707c1923f8ed to your computer and use it in GitHub Desktop.
Save trinhpham/ba5bac01b4465b49ade2707c1923f8ed to your computer and use it in GitHub Desktop.
Download file from URL with pure JJS (jre javascript)
#!/usr/bin/env jjs
var url = new java.net.URL("https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz");
var inStream = new java.io.BufferedInputStream(url.openStream());
var fileOutputStream = new java.io.FileOutputStream("openjdk-11.tar.gz");
inStream.transferTo(fileOutputStream);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment