http://www.baptiste-wicht.com/2010/08/java-7-try-with-resources-statement/
정말 매력적인 기능!! java7 쓸만 하겠다,
private static void customBufferStreamCopy(File source, File target) { try (InputStream fis = new FileInputStream(source); OutputStream fos = new FileOutputStream(target)){ byte[] buf = new byte[8192]; int i; while ((i = fis.read(buf)) != -1) { fos.write(buf, 0, i); } } catch (Exception e) { e.printStackTrace(); } }
반응형
'emotional developer > detect-Java' 카테고리의 다른 글
Building Web Applications with Maven 2 | Java.net (0) | 2010.09.16 |
---|---|
5 things you didn't know about ... Command-line flags for the JVM (0) | 2010.08.27 |
apache common validator (0) | 2010.08.04 |