此代码下载 4 个带照片的链接。有没有办法用新名称创建新的 .png 文件?例如: image1.png , image2.png, image3.png 自动
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
public class AfbeeldingDown {
public static void main(String[] args) throws IOException {
URL url = new URL("http://www.autoguide.com/auto-news/wp-content/uploads/2012/12/mazda-2013-tokyo-auto-salon.jpg");
URL url1 = new URL("http://www.autoguide.com/auto-news/wp-content/uploads/2012/12/mazda-2013-tokyo-auto-salon.jpg");
URL url2 = new URL("http://www.autoguide.com/auto-news/wp-content/uploads/2012/12/mazda-2013-tokyo-auto-salon.jpg");
URL url3 = new URL("http://www.autoguide.com/auto-news/wp-content/uploads/2012/12/mazda-2013-tokyo-auto-salon.jpg");
InputStream in = url.openStream();
OutputStream out = new FileOutputStream("image.png");
int r;
while ((r = in.read())!= -1) {
out.write(r);
}
in.close();
out.close();
}
}