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());
}
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);
}
}
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;
}
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;
}
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);
}
Aggregations