一个无限批量下载百度美女图片的demo

原理主要得益于这个有趣的发现

http://blog.csdn.net/yuanwofei/article/details/16343743


拿到图片的URL

剩下的就是无限循环遍历图片下载了

下载图片的代码

URL u = new URL(imgUrl);
		String name = imgUrl.substring(imgUrl.lastIndexOf("/") + 1,
				imgUrl.length());
		File f = new File("d:" + File.separator + "诱惑美女");
		if (!f.exists()) {
			f.mkdir();
		}
		File fileImg = new File(f, name);
		InputStream is;
		if (!fileImg.exists()) {
			is = u.openConnection().getInputStream();
			fileImg.createNewFile();
		} else {
			return;
		}
		FileOutputStream fileOutputStream = new FileOutputStream(fileImg);
		byte[] buff = new byte[1024 * 8];
		int len = 0;
		while ((len = is.read(buff)) != -1) {
			fileOutputStream.write(buff, 0, len);
		}
		fileOutputStream.close();
		is.close();


一个demo

http://download.csdn.net/detail/u012293381/8017869





你可能感兴趣的:(things,about,creation)