public static InputStreamReader readerFactory ( File file , String charset ) throws IOException { String name = file . getName ( ) ; if ( name . toLowerCase ( ) . endsWith ( ".doc" ) ) { return new DocStreamReader ( new FileInputStream ( file ) , charset ) ; } else if ( name . toLowerCase ( ) . endsWith ( ".docx" ) ) { return new DocxStreamReader ( new FileInputStream ( file ) ) ; } else if ( name . toLowerCase ( ) . endsWith ( ".odt" ) ) { return new ODFStreamReader ( new FileInputStream ( file ) ) ; } else { return new LatexStreamReader ( new FileInputStream ( file ) , charset ) ; } }
Create an InputStreamReader from a File depending on the filename .