Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStream;
- import java.net.URL;
- public class getImage {
- public static void main (String args[]) throws IOException{
- String url = "http://dummyimage.com/600x400/000/fff&text=";
- String destination = "C:\\Users\\ruudi\\Desktop\\images\\num";
- for(int i = 0; i <= 1000000; i++){
- saveImage(url, destination, i);
- System.out.println("Done " + i);
- }
- System.out.println("COMPLETE");
- }
- public static void saveImage(String imageUrl, String destination, int iter) throws IOException {
- URL url = new URL(imageUrl + iter);
- InputStream is = url.openStream();
- OutputStream os = new FileOutputStream(destination + iter + ".png");
- byte[] b = new byte[2048];
- int length;
- while((length = is.read(b)) != -1){
- os.write(b, 0, length);
- }
- is.close();
- os.close();
- }
- }
Add Comment
Please, Sign In to add comment