Skip to content

Instantly share code, notes, and snippets.

@gabrieldewes
Created December 4, 2017 14:32
Show Gist options
  • Save gabrieldewes/42aec2712cce6c781d9312a737eb235d to your computer and use it in GitHub Desktop.
Save gabrieldewes/42aec2712cce6c781d9312a737eb235d to your computer and use it in GitHub Desktop.
Baixar um arquivo de um servidor remoto
try {
URL url = new URL("http://127.0.0.1/scripts/download.php");
ReadableByteChannel readableByteChannel = Channels.newChannel(url.openStream());
FileOutputStream fileOutputStream = new FileOutputStream("resourceFileName.db");
fileOutputStream.getChannel().transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
} catch (Exception ex) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment