B4J Programming Press on the image to return to the main documentation page.

ByteConverter

This library contains a ByeConverter object that can transform arrays of primitive
types to and from arrays of Bytes specifying the "endian-ness" of the conversion
and also provides for the copying of part or all of the contents of one array to
another array of the same type.

Byte arrays can be transformed to and from a hexadecimal string representation and
Strings can be transformed to and from arrays of Bytes using specified encodings.

List of types:

ByteConverter

ByteConverter

This ByeConverter object can transform arrays of primitive types to and from arrays
of Bytes with the "endian-ness" of the conversion specified.

Byte arrays can be transformed to and from a hexadecimal string representation.

Strings can be transformed to and from arrays of Bytes using specified encodings and
to and from arrays of Chars.

An array copy method is thrown in for good measure.

Events:

None

Members:


  ArrayCopy (src As Object, srcOffset As Int, dest As Object, destOffset As Int, count As Int)

  CharsFromBytes (bytes() As Byte) As Char()

  CharsToBytes (vals() As Char) As Byte()

  DoublesFromBytes (bytes() As Byte) As Double()

  DoublesToBytes (vals() As Double) As Byte()

  FloatsFromBytes (bytes() As Byte) As Float()

  FloatsToBytes (vals() As Float) As Byte()

  FromChars (chars() As Char) As String

  HexFromBytes (bytes() As Byte) As String

  HexToBytes (hex As String) As Byte()

  IntsFromBytes (bytes() As Byte) As Int()

  IntsToBytes (vals() As Int) As Byte()

  LittleEndian As Boolean

  LongsFromBytes (bytes() As Byte) As Long()

  LongsToBytes (vals() As Long) As Byte()

  ShortsFromBytes (bytes() As Byte) As Short()

  ShortsToBytes (vals() As Short) As Byte()

  StringFromBytes (bytes() As Byte, encoding As String) As String

  StringToBytes (str As String, encoding As String) As Byte()

  SupportedEncodings As String()

  ToChars (str As String) As Char()

  Version As Double [read only]

Members description:

ArrayCopy (src As Object, srcOffset As Int, dest As Object, destOffset As Int, count As Int)
Copies count elements from the srcoffset in the src array to destoffset in the dest array.
The arrays need to be of the same type otherwise an ArrayStoreException is thrown.
CharsFromBytes (bytes() As Byte) As Char()
Takes an array of Bytes and returns an array of Chars converted from that array.
CharsToBytes (vals() As Char) As Byte()
Takes an array of Chars and returns an array of Bytes converted from that array.
DoublesFromBytes (bytes() As Byte) As Double()
Takes an array of Bytes and returns an array of Doubles converted from that array.
DoublesToBytes (vals() As Double) As Byte()
Takes an array of Doubles and returns an array of Bytes converted from that array.
FloatsFromBytes (bytes() As Byte) As Float()
Takes an array of Bytes and returns an array of Floats converted from that array.
FloatsToBytes (vals() As Float) As Byte()
Takes an array of Floats and returns an array of Bytes converted from that array.
FromChars (chars() As Char) As String
Returns a string converted from the specified array of characters.
HexFromBytes (bytes() As Byte) As String
Returns a string containing the representation in hexadecimal of the bytes in a byte array.
HexToBytes (hex As String) As Byte()
Returns an array of bytes containing the data represented by a hexadecimal string. The string can be upper or lower case.
IntsFromBytes (bytes() As Byte) As Int()
Takes an array of Bytes and returns an array of Ints converted from that array.
IntsToBytes (vals() As Int) As Byte()
Takes an array of Ints and returns an array of Bytes converted from that array.
LittleEndian As Boolean
Gets or sets the endian-ness of byte conversions to and from other primitive values.
The default for Android is Big_Endian, Windows PCs are Little_Endian.
LongsFromBytes (bytes() As Byte) As Long()
Takes an array of Bytes and returns an array of Longs converted from that array.
LongsToBytes (vals() As Long) As Byte()
Takes an array of Longs and returns an array of Bytes converted from that array.
ShortsFromBytes (bytes() As Byte) As Short()
Takes an array of Bytes and returns an array of Shorts converted from that array.
ShortsToBytes (vals() As Short) As Byte()
Takes an array of Shorts and returns an array of Bytes converted from that array.
StringFromBytes (bytes() As Byte, encoding As String) As String
Returns a string containing the bytes in the array interpreted as characters according to encoding.
StringToBytes (str As String, encoding As String) As Byte()
Returns an array of bytes containing the the characters in str converted to bytes according to encoding.
SupportedEncodings As String()
Returns a string array containing all the values for encodings that are supported by this system.
ToChars (str As String) As Char()
Returns an array of chars comprising the characters of the specified string
Version As Double [read only]
Returns the version number of this library.
Top