日期:2014-05-20 浏览次数:20922 次
URL url = new URL("http://rewalls.com/pic/201112/1920x1200/reWalls.com-57365.jpg"); // 图片不是原来的了。 ImageIO.write(ImageIO.read(url),"jpg",new File("image-01.jpg")); // BufferedInputStream input = null; BufferedOutputStream output = null; try { input = new BufferedInputStream(url.openStream()); output = new BufferedOutputStream(new FileOutputStream("/tmp/image-03.jpg")); for (int d = input.read(); d != -1; d = input.read()) { output.write(d); } } catch (Exception e) { } finally { if (input != null) { input.close(); } if (output != null) { output.close(); } } // java 7 try (InputStream in = url.openStream()) { Files.copy(in, Paths.get("/tmp","image-02.jpg")); } catch (Exception e) { }