Class ReadableResourceString

All Implemented Interfaces:
com.helger.base.iface.IHasSize, com.helger.base.io.iface.IHasByteArray, com.helger.base.io.iface.IHasInputStream, com.helger.base.io.iface.IHasInputStreamAndReader, com.helger.base.io.iface.IWriteToStream, IMemoryReadableResource, IReadableResource, IResourceBase

public class ReadableResourceString extends ReadableResourceByteArray
An in-memory IReadableResource based on a String which is converted to a byte array with the provided charset.
Author:
Philip Helger
  • Constructor Details

    • ReadableResourceString

      public ReadableResourceString(@NonNull String sString, @NonNull Charset aCharset)
      Constructor with automatic resource ID.
      Parameters:
      sString - The string content. May not be null.
      aCharset - The charset to use for converting the string to bytes. May not be null.
    • ReadableResourceString

      public ReadableResourceString(@Nullable String sResourceID, @NonNull String sString, @NonNull Charset aCharset)
      Constructor with explicit resource ID.
      Parameters:
      sResourceID - The resource ID. May be null.
      sString - The string content. May not be null.
      aCharset - The charset to use for converting the string to bytes. May not be null.
  • Method Details

    • utf8

      public static @NonNull ReadableResourceString utf8(@NonNull String sString)
      Factory method to create a UTF-8 encoded readable resource string.
      Parameters:
      sString - The string content. May not be null.
      Returns:
      A new ReadableResourceString instance. Never null.
    • utf8

      public static @NonNull ReadableResourceString utf8(@Nullable String sResourceID, @NonNull String sString)
      Factory method to create a UTF-8 encoded readable resource string with a custom resource ID.
      Parameters:
      sResourceID - The resource ID. May be null.
      sString - The string content. May not be null.
      Returns:
      A new ReadableResourceString instance. Never null.