我有這樣的方法,它嘗試下載圖片:如何將HtmlImage對象轉換爲RenderedImage?
private static void downloadImage() throws IOException {
int imgSrc = 0;
for(HtmlImage img : urlList){
String imageFormat = img.toString().substring(img.toString().lastIndexOf(".") + 1);
String imgPath = "C:\\" + imgSrc + "";
imgSrc++;
if (img != null) {
File file = new File(imgPath);
//In the next method i need img in RenderedImage type
ImageIO.write(img, imageFormat, file);
}
}
}
我怎樣才能把它轉換HtmlImage img
=>RenderedImage img
?
你只是想挽回的HtmlImage到一個文件? –
是的,正是如此) –