reader = ReaderFactory.newReader( inputStream, inputEncoding );
private Reader getDescriptorReader( ZipFile zipFile, String descriptor ) throws IOException { ZipEntry entry = searchEntry( zipFile, descriptor ); if ( entry == null ) { return null; } InputStream is = zipFile.getInputStream( entry ); if ( is == null ) { throw new IOException( "The " + descriptor + " descriptor cannot be read in " + zipFile.getName() + "." ); } return ReaderFactory.newReader( is, ReaderFactory.UTF_8 ); }
/** * Creates a new reader for the specified file, using the plugin's {@link #encoding} parameter. * * @param file The file to create a reader for, must not be <code>null</code>. * @return The reader for the file, never <code>null</code>. * @throws java.io.IOException If the specified file was not found or the configured encoding is not supported. */ private Reader newReader( File file ) throws IOException { if ( StringUtils.isNotEmpty( encoding ) ) { return ReaderFactory.newReader( file, encoding ); } else { return ReaderFactory.newPlatformReader( file ); } }
/** * Read the given file and return the content as a string. * * @param file the file * @return the string * @throws IOException Signals that an I/O exception has occurred. */ private String readFileAsString(File file) throws java.io.IOException { StringBuilder fileData = new StringBuilder(1000); BufferedReader reader = null; try { reader = new BufferedReader(ReaderFactory.newReader(file, this.encoding)); char[] buf = new char[1024]; int numRead = 0; while ((numRead = reader.read(buf)) != -1) { String readData = String.valueOf(buf, 0, numRead); fileData.append(readData); buf = new char[1024]; } } finally { IOUtil.close(reader); } return fileData.toString(); }
/** * @param f not null * @param encoding the encoding file used * @return the content of the file or null if an error occurred. */ private static String read( File f, String encoding ) { Reader reader = null; try { reader = ReaderFactory.newReader( f, encoding ); return IOUtil.toString( reader ); } catch ( IOException e ) { // nop; } finally { IOUtil.close( reader ); } return null; } }
/** * Reads a file and returns its contents without any XML comments. * * @param file the file we are reading * @param encoding the encoding file used * @return a StringBuffer with file's contents. * @throws IOException if something goes wrong. * @see ReaderFactory#newReader(File, String) * @see IOUtil#toString(Reader) */ private static String toString( File file, String encoding ) throws IOException { String content; Reader reader = null; try { reader = ReaderFactory.newReader( file, encoding ); content = IOUtil.toString( reader ); } finally { IOUtil.close( reader ); } // some link could be in comments, remove them return content.replaceAll( "(?s)<!--.*?-->", "" ); }
try reader = new BufferedReader( ReaderFactory.newReader( clirrTextOutputFile, "UTF-8" ) );
public void setInput(java.io.InputStream inputStream, String inputEncoding) throws XmlPullParserException { if(inputStream == null) { throw new IllegalArgumentException("input stream can not be null"); } Reader reader; try { if(inputEncoding != null) { reader = ReaderFactory.newReader(inputStream, inputEncoding); } else { reader = ReaderFactory.newXmlReader(inputStream); } } catch (UnsupportedEncodingException une) { throw new XmlPullParserException( "could not create reader for encoding "+inputEncoding+" : "+une, this, une); } catch ( IOException e ) { throw new XmlPullParserException( "could not create reader : "+e, this, e); } setInput(reader); //must be here as reset() was called in setInput() and has set this.inputEncoding to null ... this.inputEncoding = inputEncoding; }
public void setInput(java.io.InputStream inputStream, String inputEncoding) throws XmlPullParserException { if(inputStream == null) { throw new IllegalArgumentException("input stream can not be null"); } Reader reader; try { if(inputEncoding != null) { reader = ReaderFactory.newReader(inputStream, inputEncoding); } else { reader = ReaderFactory.newXmlReader(inputStream); } } catch (UnsupportedEncodingException une) { throw new XmlPullParserException( "could not create reader for encoding "+inputEncoding+" : "+une, this, une); } catch ( IOException e ) { throw new XmlPullParserException( "could not create reader : "+e, this, e); } setInput(reader); //must be here as reset() was called in setInput() and has set this.inputEncoding to null ... this.inputEncoding = inputEncoding; }
try r = ReaderFactory.newReader( resourceList, ReaderFactory.UTF_8 ); reader = new LineNumberReader( r );
try reader = ReaderFactory.newReader( bookFile.getFile(), context.getInputEncoding() ); doxia.parse( reader, bookFile.getParserId(), sink );
try reader = ReaderFactory.newReader( bookFile.getFile(), context.getInputEncoding() ); doxia.parse( reader, bookFile.getParserId(), sink );
reader = ReaderFactory.newReader( inputFile, inputEncoding );
try reader = ReaderFactory.newReader( bookFile.getFile(), context.getInputEncoding() ); doxia.parse( reader, bookFile.getParserId(), sink );
try reader = ReaderFactory.newReader( bookFile.getFile(), context.getInputEncoding() ); doxia.parse( reader, bookFile.getParserId(), sink );
try reader = ReaderFactory.newReader( bookFile.getFile(), context.getInputEncoding() ); doxia.parse( reader, bookFile.getParserId(), sink );
reader = ReaderFactory.newReader( f, context.getInputEncoding() );
case Parser.UNKNOWN_TYPE: default: reader = ReaderFactory.newReader( doc, siteContext.getInputEncoding() );