Java代码爬取完整图片简单工具类
util工具类
public void method01() throws Exception { URL url1 = new URL("http://pic327.nipic.com/file/20200921/24834673_104056152000_2.jpg"); URLConnection uc = url1.openConnection(); InputStream inputStream = uc.getInputStream(); FileOutputStream out = new FileOutputStream("D:\\image\\a.jpg"); int j = 0; while ((j = inputStream.read()) != -1) { out.write(j); System.out.println("图片爬取成功"); } inputStream.close(); }

浙公网安备 33010602011771号