Class HexUtil
- java.lang.Object
-
- org.hortonmachine.gears.io.dxfdwg.libs.dwg.utils.HexUtil
-
public class HexUtil extends Object
Number in hexadecimal format are used throughout Freenet.Unless otherwise stated, the conventions follow the rules outlined in the Java Language Specification.
- Author:
- syoung
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]bitsToBytes(BitSet ba, int size)Pack the bits in ba into a byte[].static StringbitsToHexString(BitSet ba, int size)Pack the bits in ba into a byte[] then convert that to a hex string and return it.static voidbytesToBits(byte[] b, BitSet ba, int maxSize)Read bits from a byte array into a bitsetstatic StringbytesToHex(byte[] bs)static StringbytesToHex(byte[] bs, int off, int length)Converts a byte array into a string of upper case hex chars.static voidbytesToHexAppend(byte[] bs, int off, int length, StringBuffer sb)static intcountBytesForBits(int size)static voidhexToBits(String s, BitSet ba, int length)Read a hex string of bits and write it into a bitsetstatic byte[]hexToBytes(String s)static voidhexToBytes(String s, byte[] out, int off)Converts a String of hex characters into an array of bytes.static byte[]hexToBytes(String s, int off)
-
-
-
Method Detail
-
bytesToHex
public static final String bytesToHex(byte[] bs, int off, int length)
Converts a byte array into a string of upper case hex chars.- Parameters:
bs- A byte arrayoff- The index of the first byte to readlength- The number of bytes to read.- Returns:
- the string of hex chars.
-
bytesToHexAppend
public static final void bytesToHexAppend(byte[] bs, int off, int length, StringBuffer sb)
-
bytesToHex
public static final String bytesToHex(byte[] bs)
-
hexToBytes
public static final byte[] hexToBytes(String s)
-
hexToBytes
public static final byte[] hexToBytes(String s, int off)
-
hexToBytes
public static final void hexToBytes(String s, byte[] out, int off) throws NumberFormatException, IndexOutOfBoundsException
Converts a String of hex characters into an array of bytes.- Parameters:
s- A string of hex characters (upper case or lower) of even length.out- A byte array of length at least s.length()/2 + offoff- The first byte to write of the array- Throws:
NumberFormatExceptionIndexOutOfBoundsException
-
bitsToBytes
public static final byte[] bitsToBytes(BitSet ba, int size)
Pack the bits in ba into a byte[].
-
bitsToHexString
public static final String bitsToHexString(BitSet ba, int size)
Pack the bits in ba into a byte[] then convert that to a hex string and return it.
-
countBytesForBits
public static int countBytesForBits(int size)
- Returns:
- the number of bytes required to represent the bitset
-
bytesToBits
public static void bytesToBits(byte[] b, BitSet ba, int maxSize)Read bits from a byte array into a bitset- Parameters:
b- the byte[] to read fromba- the bitset to write to
-
-