カヤック星人の逆だ。時代を逆行してるな。
Rubyほどのシンプルさはないけど、eclipseの補完機能の強力さを改めて思い知る。
import java.io.*; import java.net.*; public class Foo { public static void main(String[] args) throws Exception { URL url = new URL("http://ec1.images-amazon.com/images/P/4756144527.09._SCMZZZZZZZ_V44976733_.jpg"); InputStream in = url.openStream(); FileOutputStream out = new FileOutputStream("foo.jpg"); try { pipe(in, out); } finally { out.close(); in.close(); } } private static void pipe(InputStream in, OutputStream out) throws IOException { byte[] buf = new byte[1024]; int len = 0; while ((len = in.read(buf)) > 0) out.write(buf, 0, len); } }