Automate downloading files on the Internet with Java I might use it again
If the file folder has regular URL, you can drop it by turning it with a for statement. I was careful not to put a load on the other server
Reflesh.java
import java.net.*;
import java.io.*;
public class Reflesh {
public Reflesh(){
for(int k=1;k<100;k++){
try {
URL url = new URL("http://www.~~~~~~.com/music/"+k+".mp3");
URLConnection conn = url.openConnection();
InputStream in = conn.getInputStream();
File file = new File("/Users/mp3/mp3_"+k+".mp3");
FileOutputStream out = new FileOutputStream(file, false);
int b;
while((b = in.read()) != -1){
out.write(b);
}
out.close();
in.close();
}catch(MalformedURLException e){
System.out.println("mal");
continue;
}catch(IOException e) {
System.out.println("io");
continue;
}
}
}
public static void main(String args[]) {
new Reflesh();
}
}
Recommended Posts