InputStream in = null;    if ( filename != null ) { URL u = null; try { u = new URL( filename ); } catch( java.net.MalformedURLException m ) { u = null; }  try { if( u == null ) {  in = new FileInputStream( filename ); } else { in = u.openStream(); } } catch( IOException e ) { System.err.println( "There was an error " + (u == null ? "reading from the given file" : "opening the given URL") + ": " + e.getMessage()); usage( null ); System.exit( 1 ); } } else {    in = System.in; System.err.println("Reading from standard input..."); }  return in; }
InputStream in = null;    if ( filename != null ) { URL u = null; try { u = new URL( filename ); } catch( java.net.MalformedURLException m ) { u = null; }  try { if( u == null ) {   in = new FileInputStream( filename ); } else { in = u.openStream(); } } catch( IOException e ) { String err = (u == null) ? "reading from" : "opening"; System.err.println( "There was an error " + err + " the given URL" + ": " + e.getMessage()); usage( null ); System.exit( 1 ); } } else {    in = System.in; System.err.println("Reading from standard input..."); }  return in; }
    private static InputStream getInputStream( String [] args ) throws Exception {        // select the input stream to read from                InputStream in = null;                // read from file if filename is provided                if ( filename != null ) {            URL u = null;            try {                u = new URL( filename );            } catch( java.net.MalformedURLException m ) {                u = null;            }                        try {                if( u == null ) {                    // Try opening the file with the given filename                    in = new FileInputStream( filename );                } else {                    in = u.openStream();                }            } catch( IOException e ) {                System.err.println( "There was an error "                         + (u == null ? "reading from the given file" : "opening the given URL")                        + ": " + e.getMessage());                usage( null );                System.exit( 1 );            }        } else {                        // read from stdin                        in = System.in;            System.err.println("Reading from standard input...");        }                return in;    }