Q:

Pause download in Java?

I'm using this code to download a file, and I was wondering if its possible to pause the download and then resume it later, and if so how?:  
    URL url = new URL(URL);
        URLConnection conexion = url.openConnection();

        conexion.connect();
        int lenghtOfFile = conexion.getContentLength();
        lenghtOfFile /= 100;

        InputStream input = new BufferedInputStream(url.openStream());
        OutputStream output = new FileOutputStream(Path + FileName);

        byte data[] = new byte[1024];
        long total = 0;

        int count = 0;
        while ((count = input.read(data)) != -1) {
            output.write(data, 0, count);
            total += count;
        }

        output.flush();
        output.close();
        input.close();

A:

This is only possible if the server supports HTTP range headers (introduced in HTTP 1.1)
See this question for examples in Java: how to use the HTTP range header in J2ME?.
"Pausing" could just mean reading some of the stream and writing it to disk. When resuming you would have to use the headers to specify what is left to download.

