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[] |
removeSpaces(byte[] array)
Remove all spaces (32) found in the data.
|
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 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 stringCopyright © 2018. All rights reserved.