Search in sources :

Example 76 with Reader

use of java.io.Reader in project guava by hceylan.

the class MultiReaderTest method testSkip.

public void testSkip() throws Exception {
    String begin = "abcde";
    String end = "fghij";
    @SuppressWarnings("unchecked") Reader joinedReader = CharStreams.join(newReader(begin), newReader(end)).getInput();
    String expected = begin + end;
    assertEquals(expected.charAt(0), joinedReader.read());
    CharStreams.skipFully(joinedReader, 1);
    assertEquals(expected.charAt(2), joinedReader.read());
    CharStreams.skipFully(joinedReader, 4);
    assertEquals(expected.charAt(7), joinedReader.read());
    CharStreams.skipFully(joinedReader, 1);
    assertEquals(expected.charAt(9), joinedReader.read());
    assertEquals(-1, joinedReader.read());
}
Also used : StringReader(java.io.StringReader) FilterReader(java.io.FilterReader) Reader(java.io.Reader)

Example 77 with Reader

use of java.io.Reader in project hibernate-orm by hibernate.

the class DataHelper method extractString.

/**
	 * Extract the contents of the given Clob as a string.
	 *
	 * @param value The clob to to be extracted from
	 *
	 * @return The content as string
	 */
public static String extractString(final Clob value) {
    try {
        final Reader characterStream = value.getCharacterStream();
        final long length = determineLengthForBufferSizing(value);
        return length > Integer.MAX_VALUE ? extractString(characterStream, Integer.MAX_VALUE) : extractString(characterStream, (int) length);
    } catch (SQLException e) {
        throw new HibernateException("Unable to access lob stream", e);
    }
}
Also used : SQLException(java.sql.SQLException) HibernateException(org.hibernate.HibernateException) Reader(java.io.Reader) StringReader(java.io.StringReader)

Example 78 with Reader

use of java.io.Reader in project cassandra by apache.

the class StandardAnalyzer method init.

public void init(StandardTokenizerOptions tokenizerOptions, AbstractType validator) {
    this.validator = validator;
    this.options = tokenizerOptions;
    this.filterPipeline = getFilterPipeline();
    Reader reader = new InputStreamReader(new DataInputBuffer(ByteBufferUtil.EMPTY_BYTE_BUFFER, false));
    this.scanner = new StandardTokenizerImpl(reader);
    this.inputReader = reader;
}
Also used : DataInputBuffer(org.apache.cassandra.io.util.DataInputBuffer) InputStreamReader(java.io.InputStreamReader) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader)

Example 79 with Reader

use of java.io.Reader in project cassandra by apache.

the class StandardAnalyzer method reset.

public void reset(ByteBuffer input) {
    this.next = null;
    Reader reader = new InputStreamReader(new DataInputBuffer(input, false));
    scanner.yyreset(reader);
    this.inputReader = reader;
}
Also used : DataInputBuffer(org.apache.cassandra.io.util.DataInputBuffer) InputStreamReader(java.io.InputStreamReader) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader)

Example 80 with Reader

use of java.io.Reader in project es6draft by anba.

the class PropertiesReaderControl method newBundle.

@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IOException {
    if ("java.properties".equals(format)) {
        String bundleName = toBundleName(baseName, locale);
        String resourceName = toResourceName(bundleName, "properties");
        InputStream stream = getInputStream(loader, resourceName, reload);
        if (stream == null) {
            return null;
        }
        try (Reader reader = new InputStreamReader(stream, charset)) {
            return new PropertyResourceBundle(reader);
        }
    }
    throw new IllegalArgumentException("unknown format: " + format);
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) PropertyResourceBundle(java.util.PropertyResourceBundle)

Aggregations

Reader (java.io.Reader)1734 InputStreamReader (java.io.InputStreamReader)627 StringReader (java.io.StringReader)565 IOException (java.io.IOException)482 BufferedReader (java.io.BufferedReader)293 Test (org.junit.Test)253 InputStream (java.io.InputStream)252 TokenStream (org.apache.lucene.analysis.TokenStream)171 SqlSessionFactoryBuilder (org.apache.ibatis.session.SqlSessionFactoryBuilder)159 Connection (java.sql.Connection)138 FileReader (java.io.FileReader)129 ScriptRunner (org.apache.ibatis.jdbc.ScriptRunner)126 FileInputStream (java.io.FileInputStream)124 File (java.io.File)117 BeforeClass (org.junit.BeforeClass)99 Tokenizer (org.apache.lucene.analysis.Tokenizer)91 StringWriter (java.io.StringWriter)89 ArrayList (java.util.ArrayList)86 SqlSession (org.apache.ibatis.session.SqlSession)83 List (java.util.List)76