Java Code Examples for com.helger.commons.io.stream.StreamHelper#createReader()

The following examples show how to use com.helger.commons.io.stream.StreamHelper#createReader() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CharsetHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static InputStreamReader getReaderByBOM (@Nonnull final InputStream aIS,
                                                @Nonnull final Charset aFallbackCharset)
{
  ValueEnforcer.notNull (aIS, "InputStream");
  ValueEnforcer.notNull (aFallbackCharset, "FallbackCharset");

  // Determine BOM/Charset
  final InputStreamAndCharset aISAndBOM = getInputStreamAndCharsetFromBOM (aIS);

  // Create the reader with the current position of the InputStream and the
  // correct charset
  final Charset aEffectiveCharset = aISAndBOM.getCharset (aFallbackCharset);
  return StreamHelper.createReader (aISAndBOM.getInputStream (), aEffectiveCharset);
}
 
Example 2
Source File: PathHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nullable
public static Reader getReader (@Nonnull final Path aFile, @Nonnull final Charset aCharset)
{
  ValueEnforcer.notNull (aFile, "Path");
  ValueEnforcer.notNull (aCharset, "Charset");

  return StreamHelper.createReader (getInputStream (aFile), aCharset);
}
 
Example 3
Source File: FileHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nullable
public static InputStreamReader getReader (@Nonnull final File aFile, @Nonnull final Charset aCharset)
{
  ValueEnforcer.notNull (aFile, "File");
  ValueEnforcer.notNull (aCharset, "Charset");

  return StreamHelper.createReader (getInputStream (aFile), aCharset);
}
 
Example 4
Source File: FileSystemCharStreamProvider.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
@Nullable
public Reader getReader (@Nonnull final String sName)
{
  return StreamHelper.createReader (getInputStream (sName), m_aCharset);
}
 
Example 5
Source File: ClassPathResource.java    From ph-commons with Apache License 2.0 2 votes vote down vote up
/**
 * Create a {@link Reader} of this resource, using the specified class loader
 * only.
 *
 * @param aClassLoader
 *        The class loader to be used. May not be <code>null</code>.
 * @param aCharset
 *        The charset to be used for the {@link Reader}. May not be
 *        <code>null</code>.
 * @return <code>null</code> if the path could not be resolved.
 */
@Nullable
public Reader getReaderNoCache (@Nonnull final ClassLoader aClassLoader, @Nonnull final Charset aCharset)
{
  return StreamHelper.createReader (getInputStreamNoCache (aClassLoader), aCharset);
}
 
Example 6
Source File: IHasInputStreamAndReader.java    From ph-commons with Apache License 2.0 2 votes vote down vote up
/**
 * Get a {@link Reader} based on this input stream provider using the given
 * charset.
 *
 * @param aCharset
 *        The charset to use. May not be <code>null</code>.
 * @return <code>null</code> if no input stream could be retrieved.
 */
@Nullable
default Reader getReader (@Nonnull final Charset aCharset)
{
  return StreamHelper.createReader (getInputStream (), aCharset);
}