org.gjt.sp.jedit.io

## Class RegexEncodingDetector

- java.lang.Object
- - org.gjt.sp.jedit.io.RegexEncodingDetector

- All Implemented Interfaces:
    EncodingDetector

      public class RegexEncodingDetector
      extends java.lang.Object
      implements EncodingDetector

  An encoding detector which finds regex pattern. This reads the sample in the system default encoding for first some lines and look for a regex pattern. This can fail if the stream cannot be read in the system default encoding or the pattern is not found at near the top of the stream.
  Since:
    4.3pre16

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `VALID_ENCODING_PATTERN` A regex pattern matches to "Charset names" specified for java.nio.charset.Charset.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RegexEncodingDetector(java.lang.String pattern, java.lang.String replacement)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `detectEncoding(java.io.InputStream sample)` Returns the name of a detected encoding for the bytes in sample.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### VALID_ENCODING_PATTERN

          public static final java.lang.String VALID_ENCODING_PATTERN

      A regex pattern matches to "Charset names" specified for java.nio.charset.Charset.
      See Also:
        Charset names, Constant Field Values

  - ### Constructor Detail

    - #### RegexEncodingDetector

          public RegexEncodingDetector(java.lang.String pattern,
                               java.lang.String replacement)

  - ### Method Detail

    - #### detectEncoding

          public java.lang.String detectEncoding(java.io.InputStream sample)
                                          throws java.io.IOException

      Description copied from interface: `EncodingDetector`
      Returns the name of a detected encoding for the bytes in sample. Returns null if this instance could not detect reasonable one.
      Specified by:
        `detectEncoding` in interface `EncodingDetector`
      Throws:
        `java.io.IOException`