My Java code:
con = (HttpURLConnection) obj.openConnection();
con.setInstanceFollowRedirects(false);
con.setRequestProperty("X-Direct-Download", "true");
con.setRequestMethod("GET");
con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
-------------------------------OUTPUT LOG-----------------------------------------------
Downloading File: I:\2018_Work\Out\ATH-2019-03-18-NORMALIZEDMP-Data-1-of-1.csv.gz
Trying to download first time->i=0
Output File is Creating Now
responseCode:302
---------------------------------------------
Somehow getting 302 response code but its not downloading the file with streams. Here is my code which downloads file. (Link printed in logs is downloadable though)
DataInputStream readerIS = new DataInputStream(con.getInputStream());
Files.copy (readerIS, Paths.get (fileName), StandardCopyOption.REPLACE_EXISTING);
Please suggest what else is needed here.