겸손 (1) 썸네일형 리스트형 Java try-with-resources FileOutputStream을 쓸 일이 생겼다. 다른 분이 만들어 놓은 유틸 클래스가 있어서 가져다 쓰려고 봤는데, 언뜻 보니 close()가 없었다. 우선 내가 알던 고전적인 코드는 다음과 같이 작성한다. FileOutputStream fos = null; try { fos = new FileOutputStream(file); fos.write(mFile.getBytes()); } catch (IOException e) { e.printStackTrace(); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } }자원을 사용했으면 반드시 close()를 호출한다고 배웠다. .. 이전 1 다음