|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.mucommander.io.BinaryDetector
public class BinaryDetector
This class provides methods to determine whether some data is binary data or text data. As there is no formal characterization of what binary data really is, this method is an approximation at best and should not be trusted for anything critical.
The RECOMMENDED_BYTE_SIZE field indicates how many bytes should be provided for the detector to be
confident enough.
EncodingDetector| Field Summary | |
|---|---|
static int |
RECOMMENDED_BYTE_SIZE
Provides an indication as to the number of bytes that should fed to the detector for it to have enough confidence. |
| Constructor Summary | |
|---|---|
BinaryDetector()
|
|
| Method Summary | |
|---|---|
static boolean |
guessBinary(byte[] b)
This method is a shorthand for guessBinary(b, 0, b.length). |
static boolean |
guessBinary(byte[] b,
int off,
int len)
Tries and detect whether the given bytes correspond to binary or text data. |
static boolean |
guessBinary(java.io.InputStream in)
Tries and detect whether the given stream contains binary or text data. This method returns true if it thinks that the bytes correspond to binary data. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int RECOMMENDED_BYTE_SIZE
| Constructor Detail |
|---|
public BinaryDetector()
| Method Detail |
|---|
public static boolean guessBinary(byte[] b)
guessBinary(b, 0, b.length).
b - the data to analyze
public static boolean guessBinary(byte[] b,
int off,
int len)
true if it thinks that the bytes correspond to binary data.
b - the data to analyzeoff - specifies where to start reading the arraylen - specifies where to stop reading the array
public static boolean guessBinary(java.io.InputStream in)
throws java.io.IOException
true if it thinks that the bytes correspond to binary data.
A maximum of RECOMMENDED_BYTE_SIZE will be read from the InputStream. The
stream will not be closed and will not be repositionned after the bytes have been read. It is up to the calling
method to use the InputStream#mark() and InputStream#reset() methods (if supported)
or reopen the stream if needed.
in - the stream to analyze
java.io.IOException - if an error occurred while reading the InputStream.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard