title: always redirected to a different url when download is done programmatically (Java)
body: <p>This is what I need to do.
  I need to download a bunch of apks from a market.
  Analyze each file if it contains ads inside using Multi-apk tool and compress it again (This is not the issue so I won'd discuss it any further)</p>
  
  <p>Right now, I'm doing the part wherein I will download apk from a particular market.
  I get the source code of the page and get all URLS that ends with .APK</p>
  
  <p>After each URL is extracted from the page, I download it using commons io.
  However, whenever a download is complete, I noticed that all of them is the same in size. Which makes me think that it is downloading the same file. </p>
  
  <p>I tried using wget, and I found out that all of the urls are redirected to one url.</p>
  
  <p>When I go to page and download that same file by clicking the button that says "download to PC", it works properly and downloaded the file that I want.</p>
  
  <p>Is there any way that I could download the files that I want? Can I modify something to the code to get the correct APK? Is this one of the capability in web programming?  </p>
  
  <p>Here's the code that downloads the APK</p>
  
  <pre><code>private static void downloadSample(String directLink) throws Exception
      {
          String[] getAPKName = directLink.split("/");
          System.out.println(getAPKName[getAPKName.length -1]);
          String APKName = getAPKName[getAPKName.length -1];        
          org.apache.commons.io.FileUtils.copyURLToFile(new URL(directLink), new File("C:\\Users\\Documents\\NetBeansProjects\\JavaApplication21\\APK\\"
  + APKName));
  
      }
  </code></pre>