Class UnicodeReader

java.lang.Object
java.io.Reader
de.elo.utils.io.UnicodeReader
All Implemented Interfaces:
Closeable, AutoCloseable, Readable

public class UnicodeReader extends Reader

Überschrift: UnicodeReader.

Beschreibung: Generic unicode textreader, which will use BOM mark to identify the encoding to be used. If BOM is not found then use a given default encoding. System default is used if: BOM mark is not found and defaultEnc is NULL Usage pattern: String defaultEnc = "ISO-8859-1"; // or NULL to use system default FileInputStream fis = new FileInputStream(file); Reader in = new UnicodeReader(fis, defaultEnc);

Copyright: Copyright (c) ELO Digital Office GmbH 2018 - 2022

  • Constructor Details

    • UnicodeReader

      public UnicodeReader(InputStream is, String defaultEncoding)
      Konstruktor.
      Parameters:
      is - InputStream
      defaultEncoding - Default-Kodierung
  • Method Details

    • getDefaultEncoding

      public String getDefaultEncoding()
      Liefert die Default-Kodierung zurück.
      Returns:
      Default-Kodierung
    • getEncoding

      public String getEncoding()
      Liefert die Kodierung zurück.
      Returns:
      Kodierung
    • init

      public void init() throws IOException
      Read-ahead four bytes and check for BOM marks. Extra bytes are unread back to the stream, only BOM bytes are skipped.
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class Reader
      Throws:
      IOException
    • read

      public int read(char[] cbuf, int off, int len) throws IOException
      Specified by:
      read in class Reader
      Throws:
      IOException