1 package org.splat.launcher;
3 import java.io.BufferedOutputStream;
4 import java.io.FileOutputStream;
5 import java.io.IOException;
6 import java.io.InputStream;
7 import java.io.OutputStream;
9 import java.net.URLConnection;
11 public class FileTransfer {
13 private final static int SIZE = 1024;
15 public static void download(final String path, final String filename,
16 final String destination) {
17 URLConnection conx = null; // Communication link between the application and a URL.
18 InputStream is = null;
19 OutputStream os = null;
23 // int ByteWritten = 0;
26 os = new BufferedOutputStream(new FileOutputStream(destination
28 // The URLConnection object is created by invoking the openConnection method on a URL.
30 conx = url.openConnection();
31 is = conx.getInputStream();
33 int ByteRead = is.read(buf);
34 while (ByteRead != -1) {
35 os.write(buf, 0, ByteRead);
36 ByteRead = is.read(buf);
38 // System.out.println("File \"" + filename + "\" successfully downloaded");
39 } catch (Exception e) {
40 e.printStackTrace(); // RKV: NOPMD: TODO: try to use logger
45 } catch (IOException e) {
46 e.printStackTrace(); // RKV: NOPMD: TODO: try to use logger