String fileName = "1.txt"; //The file that will be saved on your computer URL link = new URL("http://delivery.acm.org/10.1145/2340000/2333745/p367-rogers.pdf?ip=14.139.236.219&id=2333745&acc=ACTIVE%20SERVICE&key=045416EF4DDA69D9.F1486EDFD37746FC.4D4702B0C3E38B35.4D4702B0C3E38B35&CFID=493229062&CFTOKEN=47839990&__acm__=1427535499_1f0bc4b26af326afb3e683fc4f578624"); //The file that you want to download //Code to download InputStream in = new BufferedInputStream(link.openStream()); ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] buf = new byte[2048]; int n = 0; while (-1!=(n=in.read(buf))) { out.write(buf, 0, n); } out.close(); in.close(); byte[] response = out.toByteArray(); FileOutputStream fos = new FileOutputStream(fileName); fos.write(response); fos.close();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)