Friday, May 13, 2011

Image Downloader source code in Java and Manga downloader

import java.io.BufferedOutputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.InputStream;

import java.io.OutputStream;

import java.net.URL;



public class ImagesDownloader {

    public static void main(String[] args) throws IOException {

        getImages();

    }

    

    private static void getImages() throws IOException {

        String imagesRootPath = "http://somemanga.com/images2/";

  

            // http://somemanga.com/images2/13342848.jpg

            // http://i999.mangareader.net/naruto/538/naruto-2251381.jpg

            for (int i = 13342848; i <= 13342848+9; i++) {

                URL url = new URL(String.format("%s%d.jpg", imagesRootPath, i));

                InputStream in = url.openStream();

                OutputStream out = new BufferedOutputStream(new FileOutputStream(String.format("D:/exam/RMI Assignment update/%d.jpg", i)));

                for (int b; (b = in.read()) != -1; ) {

                    out.write(b);

                }

                out.close();

                in.close();

                System.out.println(String.format("Image %d.jpg from folder %s has been successfully downloaded.", i,imagesRootPath ));

            }

        

    }

}

No comments:

Post a Comment

How to Generate and use the ssh key on Gerrit, github.io, gitlab, and bitbucket.

 Details can be found here -