Class ReadAdapter

java.lang.Object
com.norconex.importer.util.ReadAdapter

public class ReadAdapter extends Object
  • Constructor Details

  • Method Details

    • asInputStream

      public InputStream asInputStream()
    • asReader

      public Reader asReader()
    • asReader

      public Reader asReader(Charset charset)
    • asString

      public String asString() throws IOException
      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 using asChunkedText(FailableBiFunction) instead. The input Charset is 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

      public String asString(Charset charset) throws IOException
      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 using asChunkedText(FailableBiFunction) instead. The supplied Charset will be used as the input character set if not null. 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 or null
      Returns:
      input as string
      Throws:
      IOException - could not read input
    • asChunkedText

      public boolean asChunkedText(@NonNull @NonNull FailableBiFunction<Integer,String,Boolean,IOException> textConsumer) throws IOException
      Consumes the source as chunks of text.
      Parameters:
      textConsumer - text chunk consumer
      Returns:
      true if the text was all read, false if 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,Boolean,IOException> textConsumer, ReadAdapter.ChunkedReadOptions chunkedReadOptions) throws IOException
      Throws:
      IOException