public final class DBFUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
close(Closeable closeable)
Closes silently a #
Closeable. |
static boolean |
contains(byte[] array,
byte value)
Checks that a byte array contains some specific byte
|
static byte[] |
doubleFormating(Number num,
Charset charset,
int fieldLength,
int sizeDecimalPart)
Format a double number to write to a dbf file
|
static boolean |
isPureAscii(byte[] data)
Test if the data in the array is pure ASCII
|
static boolean |
isPureAscii(String stringToCheck)
Checks if a string is pure Ascii
|
static int |
littleEndian(int value)
Convert an int value to littleEndian
|
static short |
littleEndian(short value)
Convert a short value to littleEndian
|
static int |
readLittleEndianInt(DataInput in)
Read a littleEndian integer(32b its) from DataInput
|
static short |
readLittleEndianShort(DataInput in)
Read a littleEndian short(16 bits) from DataInput
|
static Number |
readNumericStoredAsText(DataInputStream dataInput,
int length)
Reads a number from a stream,
|
static byte[] |
removeNullBytes(byte[] array)
Remove all nulls (0) found in the data.
|
static byte[] |
removeSpaces(byte[] array)
Remove all spaces (32) found in the data.
|
static void |
skip(InputStream inputStream,
long bytesToSkip)
Safely skip bytesToSkip bytes (in some bufferd scenarios skip doesn't really skip all requested bytes)
|
static byte[] |
textPadding(String text,
Charset charset,
int length)
pad a string and convert it to byte[] to write to a dbf file (by default, add whitespaces to the end of the string)
|
static byte[] |
textPadding(String text,
Charset charset,
int length,
DBFAlignment alignment,
byte paddingByte)
pad a string and convert it to byte[] to write to a dbf file
|
static Object |
toBoolean(byte t_logical)
Convert LOGICAL (L) byte to boolean value
|
static byte[] |
trimRightSpaces(byte[] b_array)
Trims right spaces from string
|
public static Number readNumericStoredAsText(DataInputStream dataInput, int length) throws IOException
dataInput - the stream datalength - the legth of the numberIOException - if an IO error happensEOFException - if reached end of file before length bytespublic static int readLittleEndianInt(DataInput in) throws IOException
in - DataInput to read fromIOException - if an IO error happensEOFException - if reached end of file before 4 bytes are readedpublic static short readLittleEndianShort(DataInput in) throws IOException
in - DataInput to read fromIOException - if an IO error happenspublic static byte[] removeSpaces(byte[] array)
array - the datapublic static byte[] removeNullBytes(byte[] array)
array - the datapublic static short littleEndian(short value)
value - value to be convertedpublic static int littleEndian(int value)
value - value to be convertedpublic static byte[] textPadding(String text, Charset charset, int length)
text - The text to be paddedcharset - Charset to use to encode the stringlength - Size of the padded stringpublic static byte[] textPadding(String text, Charset charset, int length, DBFAlignment alignment, byte paddingByte)
text - The text to be paddedcharset - Charset to use to encode the stringlength - Size of the padded stringalignment - alignment to use to paddpaddingByte - the byte used to pad the stringpublic static byte[] doubleFormating(Number num, Charset charset, int fieldLength, int sizeDecimalPart)
num - number to formatcharset - charset to usefieldLength - field lengthsizeDecimalPart - decimal part sizepublic static boolean contains(byte[] array,
byte value)
array - The array to search invalue - The byte to search forpublic static boolean isPureAscii(String stringToCheck)
stringToCheck - the stringpublic static boolean isPureAscii(byte[] data)
data - data to checkpublic static Object toBoolean(byte t_logical)
t_logical - The byte value as stored in the filepublic static byte[] trimRightSpaces(byte[] b_array)
b_array - the stringpublic static void close(Closeable closeable)
Closeable.
it can be null or throws an exception, will be ignored.closeable - The item to closepublic static void skip(InputStream inputStream, long bytesToSkip) throws IOException
inputStream - the inputstreambytesToSkip - number of bytes to skipIOException - if some IO error happensCopyright © 2020. All rights reserved.