| java.lang.Object org.apache.java.lang.Bytes
Bytes | public class Bytes (Code) | | Static methods for managing byte arrays (all methods follow Big
Endian order where most significant bits are in front).
author: Stefano Mazzocchi version: $Id: Bytes.java 264148 2005-08-29 14:21:04Z henning $ |
Method Summary | |
public static byte[] | append(byte[] a, byte[] b) Appends two bytes array into one.
Parameters: a - A byte[]. Parameters: b - A byte[]. | public static byte[] | append(byte[] a, byte[] b, byte[] c) Appends three bytes array into one.
Parameters: a - A byte[]. Parameters: b - A byte[]. Parameters: c - A byte[]. | public static boolean | areEqual(byte[] a, byte[] b) Compares two byte arrays for equality.
Parameters: a - A byte[]. Parameters: b - A byte[]. | public static byte[] | copy(byte[] b, int pos) Gets the end of the byte array given.
Parameters: b - A byte[]. Parameters: pos - The position from which to start. | public static byte[] | copy(byte[] b, int pos, int length) Gets a sub-set of the byte array given.
Parameters: b - A byte[]. Parameters: pos - The position from which to start. Parameters: length - The number of bytes to copy from the originalbyte array to the new one. | public static void | merge(byte[] src, byte[] dest) Merges a bytes array into another. | public static void | merge(byte[] src, byte[] dest, int pos) Merges a bytes array into another starting from the
given position. | public static void | merge(byte[] src, byte[] dest, int pos, int length) Merges a bytes array into another starting from the
given position. | public static void | merge(byte[] src, byte[] dest, int srcpos, int destpos, int length) Merges a bytes array into another starting from the
given positions. | public static byte[] | toBytes(int n) Returns a 4-byte array built from an int.
Parameters: n - The number to convert. | public static byte[] | toBytes(int n, byte[] b) Build a 4-byte array from an int. | public static byte[] | toBytes(long n) Returns a 8-byte array built from a long.
Parameters: n - The number to convert. | public static byte[] | toBytes(long n, byte[] b) Build a 8-byte array from a long. | public static int | toInt(byte[] b) Build an int from first 4 bytes of the array.
Parameters: b - The byte[] to convert. | public static long | toLong(byte[] b) Build a long from first 8 bytes of the array.
Parameters: b - The byte[] to convert. | public static String | toString(byte[] b) Returns a string of hexadecimal digits from a byte array.
Parameters: b - The byte[] to convert. | public static String | toString(byte[] b, int offset, int length) Returns a string of hexadecimal digits from a byte array,
starting at offset and continuing for length bytes.
Parameters: b - The byte[] to convert. Parameters: offset - An int. Parameters: length - An int. |
append | public static byte[] append(byte[] a, byte[] b)(Code) | | Appends two bytes array into one.
Parameters: a - A byte[]. Parameters: b - A byte[]. A byte[]. |
append | public static byte[] append(byte[] a, byte[] b, byte[] c)(Code) | | Appends three bytes array into one.
Parameters: a - A byte[]. Parameters: b - A byte[]. Parameters: c - A byte[]. A byte[]. |
areEqual | public static boolean areEqual(byte[] a, byte[] b)(Code) | | Compares two byte arrays for equality.
Parameters: a - A byte[]. Parameters: b - A byte[]. True if the arrays have identical contents. |
copy | public static byte[] copy(byte[] b, int pos)(Code) | | Gets the end of the byte array given.
Parameters: b - A byte[]. Parameters: pos - The position from which to start. A byte[] consisting of the portion of b between pos andthe end of b. |
copy | public static byte[] copy(byte[] b, int pos, int length)(Code) | | Gets a sub-set of the byte array given.
Parameters: b - A byte[]. Parameters: pos - The position from which to start. Parameters: length - The number of bytes to copy from the originalbyte array to the new one. A byte[] consisting of the portion of b starting at posand continuing for length bytes, or until the end of b isreached, which ever occurs first. |
merge | public static void merge(byte[] src, byte[] dest)(Code) | | Merges a bytes array into another.
Parameters: src - A byte[]. Parameters: dest - A byte[]. |
merge | public static void merge(byte[] src, byte[] dest, int pos)(Code) | | Merges a bytes array into another starting from the
given position.
Parameters: src - A byte[]. Parameters: dest - A byte[]. Parameters: pos - The position from which to start. |
merge | public static void merge(byte[] src, byte[] dest, int pos, int length)(Code) | | Merges a bytes array into another starting from the
given position.
Parameters: src - A byte[]. Parameters: dest - A byte[]. Parameters: pos - The position from which to start. Parameters: length - The number of bytes to merge. |
merge | public static void merge(byte[] src, byte[] dest, int srcpos, int destpos, int length)(Code) | | Merges a bytes array into another starting from the
given positions.
Parameters: src - A byte[]. Parameters: dest - A byte[]. Parameters: srcpos - The position from which to start in src. Parameters: destpos - The position from which to start in dest. Parameters: length - The number of bytes to merge. |
toBytes | public static byte[] toBytes(int n)(Code) | | Returns a 4-byte array built from an int.
Parameters: n - The number to convert. A byte[]. |
toBytes | public static byte[] toBytes(int n, byte[] b)(Code) | | Build a 4-byte array from an int. No check is performed on the
array length.
Parameters: n - The number to convert. Parameters: b - The array to fill. A byte[]. |
toBytes | public static byte[] toBytes(long n)(Code) | | Returns a 8-byte array built from a long.
Parameters: n - The number to convert. A byte[]. |
toBytes | public static byte[] toBytes(long n, byte[] b)(Code) | | Build a 8-byte array from a long. No check is performed on the
array length.
Parameters: n - The number to convert. Parameters: b - The array to fill. A byte[]. |
toInt | public static int toInt(byte[] b)(Code) | | Build an int from first 4 bytes of the array.
Parameters: b - The byte[] to convert. An int. |
toLong | public static long toLong(byte[] b)(Code) | | Build a long from first 8 bytes of the array.
Parameters: b - The byte[] to convert. A long. |
toString | public static String toString(byte[] b)(Code) | | Returns a string of hexadecimal digits from a byte array.
Parameters: b - The byte[] to convert. A String. |
toString | public static String toString(byte[] b, int offset, int length)(Code) | | Returns a string of hexadecimal digits from a byte array,
starting at offset and continuing for length bytes.
Parameters: b - The byte[] to convert. Parameters: offset - An int. Parameters: length - An int. A String. |
|
|