public File save ( File aFileName ) throws IOException { BufferedOutputStream bos = new BufferedOutputStream ( new FileOutputStream ( aFileName ) , 1024 ) ; byte [ ] buffer = new byte [ 1024 ] ; int len = - 1 ; while ( ( len = inputStream . read ( buffer ) ) != - 1 ) { bos . write ( buffer , 0 , len ) ; } bos . close ( ) ; inputStream . close ( ) ; return aFileName ; }
Save the contents of the resource to a file . This reads the data from the stream and stores it into the given file . Depending on the resource the data might or might not be available afterwards .