question: private void copyResource ( InputStream resource , File file ) throws IOException { try ( OutputStream out = new FileOutputStream ( file ) ) { int length ; byte [ ] buf = new byte [ 1024 ] ; while ( ( length = resource . read ( buf ) ) > 0 ) out . write ( buf , 0 , length ) ; } }
target:  Write a resource represented by an input stream into a file.