Package com.norconex.importer.util
Class ReadAdapter
java.lang.Object
com.norconex.importer.util.ReadAdapter
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionReadAdapter(InputStream inputStream) ReadAdapter(Supplier<InputStream> inputSupplier) ReadAdapter(Supplier<InputStream> inputSupplier, Charset defaultCharset) -
Method Summary
Modifier and TypeMethodDescriptionbooleanasChunkedText(@NonNull FailableBiFunction<Integer, String, Boolean, IOException> textConsumer) Consumes the source as chunks of text.booleanasChunkedText(@NonNull FailableBiFunction<Integer, String, Boolean, IOException> textConsumer, ReadAdapter.ChunkedReadOptions chunkedReadOptions) asReader()asString()Consumes the input as a string.Consumes the input as a string.
-
Constructor Details
-
ReadAdapter
-
ReadAdapter
-
ReadAdapter
-
-
Method Details
-
asInputStream
-
asReader
-
asReader
-
asString
Consumes the input as a string. Caution: Use only when you know the content to be of acceptable size. Content too large can generate memory exceptions when read as a string. An alternative is usingasChunkedText(FailableBiFunction)instead. The inputCharsetis presumed to be the one passed in the constructor or if not set, then UTF-8. in the constructor or, default to UTF-8.- Returns:
- input as string
- Throws:
IOException- could not read input
-
asString
Consumes the input as a string. Caution: Use only when you know the content to be of acceptable size. Content too large can generate memory exceptions when read as a string. An alternative is usingasChunkedText(FailableBiFunction)instead. The suppliedCharsetwill be used as the input character set if notnull. Else, it is presumed to be the one passed in the constructor or if not set there either, then UTF-8.- Parameters:
charset- the character set of the input ornull- Returns:
- input as string
- Throws:
IOException- could not read input
-
asChunkedText
public boolean asChunkedText(@NonNull @NonNull FailableBiFunction<Integer, String, throws IOExceptionBoolean, IOException> textConsumer) Consumes the source as chunks of text.- Parameters:
textConsumer- text chunk consumer- Returns:
trueif the text was all read,falseif it was aborted by the consumer, without consideration whether it was all read or not.- Throws:
IOException
-
asChunkedText
public boolean asChunkedText(@NonNull @NonNull FailableBiFunction<Integer, String, throws IOExceptionBoolean, IOException> textConsumer, ReadAdapter.ChunkedReadOptions chunkedReadOptions) - Throws:
IOException
-