Package org.gjt.sp.jedit.io
Class AutoDetection
- java.lang.Object
-
- org.gjt.sp.jedit.io.AutoDetection
-
public class AutoDetection extends java.lang.ObjectSome functions for auto detection of I/O stream properties.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAutoDetection.ResultAn utility class to hold the result of some auto detections.
-
Constructor Summary
Constructors Constructor Description AutoDetection()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgetDetectedEncoding(java.io.BufferedInputStream markedStream)Returns an auto detected encoding from content of markedStream.static java.util.List<EncodingDetector>getEncodingDetectors()Returns the user configured ordered list of encoding detectors.static java.io.BufferedInputStreamgetMarkedStream(java.io.InputStream in)Returns a marked, rewindable stream.static booleanisGzipped(java.io.InputStream sample)Returns wheather the stream is gzipped.
-
-
-
Method Detail
-
getMarkedStream
public static java.io.BufferedInputStream getMarkedStream(java.io.InputStream in)
Returns a marked, rewindable stream. Calling reset() method rewinds the stream to its beginning. But reset() can fail if too long bytes were read.
-
isGzipped
public static boolean isGzipped(java.io.InputStream sample) throws java.io.IOExceptionReturns wheather the stream is gzipped. This method reads a few bytes from the sample. So a caller must take care of mark() to reuse the contents. Wraping the stream by getMarkedStream() is suitable.- Throws:
java.io.IOException
-
getEncodingDetectors
public static java.util.List<EncodingDetector> getEncodingDetectors()
Returns the user configured ordered list of encoding detectors. This method reads property "encodingDetectors".
-
getDetectedEncoding
public static java.lang.String getDetectedEncoding(java.io.BufferedInputStream markedStream) throws java.io.IOExceptionReturns an auto detected encoding from content of markedStream. This method assumes that markedStream is wrapped by getMarkedStream() method.- Throws:
java.io.IOException
-
-