I'm trying to download file from internet using java but there have a problem. I'm not failed but each time when I'm trying to download it's downloading only 250-300 KB only though the file size is larger than that. I have tried a lot of ways but every time the result is same.
I have tried Apache Commons IO like this,
import java.io.File;
import java.net.URL;
import org.apache.commons.io.FileUtils;
public class Main {
    public static void main(String[] args) {
        try {
            String from = "https://download.gimp.org/mirror/pub/gimp/v2.8/gimp-2.8.10.tar.bz2";
            String to = "/home/ashik/gimp-2.8.10.tar.bz2";
            System.out.println("Starting!");
            FileUtils.copyURLToFile(new URL(from), new File(to), Integer.MAX_VALUE, Integer.MAX_VALUE);
            System.out.println("Finished!");
        } catch (Exception e) {
            System.err.println(e.toString());
        }
    }
}
I have tried Java NIO like this,
import java.io.FileOutputStream;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
public class Main {
    public static void main(String[] args) {
        try {
            String from = "https://download.gimp.org/mirror/pub/gimp/v2.8/gimp-2.8.10.tar.bz2";
            String to = "/home/ashik/gimp-2.8.10.tar.bz2";
            System.out.println("Starting!");
            ReadableByteChannel rbc = Channels.newChannel(new URL(from).openStream());
            FileOutputStream fos = new FileOutputStream(to);
            fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
            fos.close();
            rbc.close();
            System.out.println("Finished!");
        } catch (Exception e) {
            System.err.println(e.toString());
        }
    }
}
I have also followed some stackoverflow solutions like, How to download and save a file from Internet using Java? , How to download large sized Files (size > 50MB) in java, etc but none of them are working.
Every time it's downloading but file size is only 250-300 KB. How to solve this problem?
Platform:
OS: Debian-9
JDK-Version: Oracle JDK-9
IDE: Eclipse Oxygen
Thank you in advance.
 
     
    