public static InputStream openFile ( File file ) throws RuntimeIOException { try { InputStream is = new BufferedInputStream ( new FileInputStream ( file ) ) ; if ( file . getName ( ) . endsWith ( ".gz" ) ) { is = new GZIPInputStream ( is ) ; } return is ; } catch ( Exception e ) { throw new RuntimeIOException ( e ) ; } }
Quietly opens a File . If the file ends with a . gz extension automatically opens a GZIPInputStream to wrap the constructed FileInputStream .