protected Reader toReader ( Object input ) throws IOException { if ( input instanceof Reader ) { return ( Reader ) input ; } if ( input instanceof InputStream ) { return new InputStreamReader ( ( InputStream ) input ) ; } if ( input instanceof String ) { return new StringReader ( ( String ) input ) ; } if ( input instanceof URL ) { return new InputStreamReader ( ( ( URL ) input ) . openStream ( ) ) ; } if ( input instanceof File ) { return new FileReader ( ( File ) input ) ; } throw new IllegalArgumentException ( "Unable to turn " + input + " into reader" ) ; }
Turns input into a Reader .