Class LCSDetectionInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- oracle.i18n.lcsd.LCSDetectionInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
LCSDetectionHTMLInputStream
public class LCSDetectionInputStream extends FilterInputStream
TheLCSDetectionInputStream
class is the language and character detector stream class that transparently detects the language and character set for the stream object.The output of
read
methods are the original contents of the input stream in its original state. If the character set conversion using the detected character set is needed, use theLCSDetectionReader
class. If the input stream includes the HTML contents, use theLCSDetectionHTMLInputStream
class or theLCSDetectionHTMLReader
class. TheLCSDetectionInputStream
class is used to determine the language and character set information used in the content.- Since:
- 10.2
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
DEFAULT_SAMPLING_SIZE
Default buffer size for the dual stream objects.-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description LCSDetectionInputStream(InputStream in)
Constructs the default LCS Detector input stream object.LCSDetectionInputStream(InputStream in, int size)
Constructs the default LCS Detector input stream object with the sampling length.LCSDetectionInputStream(String profile, InputStream in)
Constructs the LCS Detector input stream object using the specified LCSD profile.LCSDetectionInputStream(String profile, InputStream in, int size)
Constructs the LCS Detector input stream object using the specified LCSD profile, input stream object, and sampling length.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LCSDResultSet
getResult()
Returns the result set of LCSD.int
read()
Reads the next byte of data from the input stream.int
read(byte[] b)
Reads some number of bytes from the input stream and stores them into the buffer arrayb
.int
read(byte[] b, int off, int len)
Reads up tolen
bytes of data from the input stream into an array of bytes.-
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, reset, skip
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Field Detail
-
DEFAULT_SAMPLING_SIZE
protected static final int DEFAULT_SAMPLING_SIZE
Default buffer size for the dual stream objects.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LCSDetectionInputStream
public LCSDetectionInputStream(InputStream in) throws IOException, UTFDataFormatException
Constructs the default LCS Detector input stream object.- Parameters:
in
- the input stream to be sampled by the detector- Throws:
IOException
- if any I/O error occursUTFDataFormatException
- if an UTF-8 data sequence is detected. Note this occurs only if the source is UTF-8 data.
-
LCSDetectionInputStream
public LCSDetectionInputStream(InputStream in, int size) throws IOException, UTFDataFormatException
Constructs the default LCS Detector input stream object with the sampling length.- Parameters:
in
- the input stream to be sampled by the detectorsize
- the sampling size- Throws:
IOException
- if any I/O error occursUTFDataFormatException
- if an invalid UTF-8 data sequence is detected. Note this occurs only if the source is UTF-8 data.
-
LCSDetectionInputStream
public LCSDetectionInputStream(String profile, InputStream in) throws IOException, UTFDataFormatException
Constructs the LCS Detector input stream object using the specified LCSD profile.- Parameters:
profile
- the LCSD profile name. Specifynull
for the default profile.in
- the input stream to be sampled by the detector- Throws:
IOException
- if any I/O error occursUTFDataFormatException
- if an invalid UTF-8 data sequence is detected. Note this occurs only if the source is UTF-8 data.
-
LCSDetectionInputStream
public LCSDetectionInputStream(String profile, InputStream in, int size) throws IOException, UTFDataFormatException
Constructs the LCS Detector input stream object using the specified LCSD profile, input stream object, and sampling length.The sampling is performed for the specified length. The detection result does not change until the read operation exceeds the specified length. Each minimum data length will be sampled afterwards.
- Parameters:
profile
- the LCSD profile name. Specifynull
for the default profile.in
- the input stream to be sampled by the detectorsize
- the sampling length- Throws:
IOException
- if any I/O error occursUTFDataFormatException
- if an invalid UTF-8 data sequence is detected. Note this occurs only if the source is UTF-8 data.
-
-
Method Detail
-
getResult
public LCSDResultSet getResult() throws IOException, EOFException, UTFDataFormatException
Returns the result set of LCSD.If your application requires information about the language, the character set, or both, call this method.
- Returns:
- The result set of LCSD.
- Throws:
IOException
- if an I/O error occursEOFException
- if the stream ends unexpectedlyUTFDataFormatException
- if an invalid UTF-8 data sequence is detected. Note this occurs only if the source is UTF-8 data.
-
read
public int read() throws IOException, UTFDataFormatException
Reads the next byte of data from the input stream.- Overrides:
read
in classFilterInputStream
- Returns:
- The next byte of data, or
-1
if the end of the stream is reached. - Throws:
IOException
- if an I/O error occursUTFDataFormatException
- if an invalid UTF-8 data sequence is detected. Note this occurs only if the source is UTF-8 data.
-
read
public int read(byte[] b) throws IOException, UTFDataFormatException
Reads some number of bytes from the input stream and stores them into the buffer arrayb
.- Overrides:
read
in classFilterInputStream
- Parameters:
b
- the buffer into which the data is read- Returns:
- The total number of bytes read into the buffer, or
-1
if there is no more data because the end of the stream has been reached. - Throws:
IOException
- if an I/O error occursUTFDataFormatException
- if an invalid UTF-8 data sequence is detected. Note this occurs only if the source is UTF-8 data.
-
read
public int read(byte[] b, int off, int len) throws IOException, UTFDataFormatException
Reads up tolen
bytes of data from the input stream into an array of bytes.- Overrides:
read
in classFilterInputStream
- Parameters:
b
- the buffer into which the data is readoff
- the start offset in arrayb
to where the data is writtenlen
- the maximum number of bytes to read- Returns:
- The total number of bytes read into the buffer, or
-1
if there is no more data because the end of the stream has been reached. - Throws:
IOException
- if an I/O error occursUTFDataFormatException
- if an invalid UTF-8 data sequence is detected. Note this occurs only if the source is UTF-8 data.
-
-