java - How to download file from URL all * files -


i download *.dmg files particular url using java code. e.g. http://testurl.com/filerepository/ host *.dmg , *.dmg files original file names using java program , store them original file name local drive.

i able download individual files if know file name problem don't know file names, know these files dmg files.

please answer. below sample program

public static void main(string[] args) throws ioexception {

    string filename = "mypackage.dmg"; //the file saved on computer     url link = new url("http://mytesturl/filerepository/"+filename);   //code download      inputstream in = new bufferedinputstream(link.openstream());      bytearrayoutputstream out = new bytearrayoutputstream();      byte[] buf = new byte[1024];      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();  //end download code       system.out.println("finished"); } 


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -