private void writeToFile ( String filename , File outputDir ) { File outFile = new File ( outputDir , filename ) ; OutputStream os ; try { os = new FileOutputStream ( outFile ) ; } catch ( FileNotFoundException e ) { throw new UIMARuntimeException ( e ) ; } InputStream is = null ; try { is = ResourceHelper . getInputStream ( "viewer/" + filename ) ; byte [ ] buf = new byte [ 1024 ] ; int numRead ; while ( ( numRead = is . read ( buf ) ) > 0 ) { os . write ( buf , 0 , numRead ) ; } } catch ( IOException e ) { throw new UIMARuntimeException ( e ) ; } finally { try { is . close ( ) ; } catch ( IOException e ) { // ignore close errors } try { os . close ( ) ; } catch ( IOException e ) { // ignore close errors } } }
Writes a resource file to disk . The resource file is looked up in the classpath