public abstract class HexUtils extends Object
| 构造器和说明 |
|---|
HexUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
biToHex(BigInteger bi)
Turn a BigInteger into a hex string.
|
static byte[] |
bitsToBytes(BitSet ba,
int size) |
static String |
bitsToHexString(BitSet ba,
int size) |
static void |
bytesToBits(byte[] b,
BitSet ba,
int maxSize) |
static String |
bytesToHex(byte[] bs) |
static String |
bytesToHex(byte[] bs,
int off,
int length)
Converts a byte array into a string of lower case hex chars.
|
static void |
bytesToHexAppend(byte[] bs,
int off,
int length,
StringBuilder sb) |
static int |
countBytesForBits(int size) |
static void |
hexToBits(String s,
BitSet ba,
int length)
Read a hex string of bits and write it into a bitset
|
static byte[] |
hexToBytes(String s) |
static void |
hexToBytes(String s,
byte[] out,
int off)
Converts a String of hex characters into an array of bytes.
|
static byte[] |
hexToBytes(String s,
int off) |
static BigInteger |
readBigInteger(DataInputStream dis)
Read a (reasonably short) BigInteger from a DataInputStream
|
static void |
writeBigInteger(BigInteger integer,
DataOutputStream out)
Write a (reasonably short) BigInteger to a stream.
|
public static final String bytesToHex(byte[] bs, int off, int length)
bs - A byte arrayoff - The index of the first byte to readlength - The number of bytes to read.public static final void bytesToHexAppend(byte[] bs,
int off,
int length,
StringBuilder sb)
public static final String bytesToHex(byte[] bs)
public static final byte[] hexToBytes(String s)
public static final byte[] hexToBytes(String s, int off)
public static final void hexToBytes(String s, byte[] out, int off) throws NumberFormatException, IndexOutOfBoundsException
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 arrayNumberFormatExceptionIndexOutOfBoundsExceptionpublic static final byte[] bitsToBytes(BitSet ba, int size)
public static int countBytesForBits(int size)
public static void bytesToBits(byte[] b,
BitSet ba,
int maxSize)
public static void hexToBits(String s, BitSet ba, int length)
s - hex string of the stored bitsba - the bitset to store the bits inlength - the maximum number of bits to storepublic static void writeBigInteger(BigInteger integer, DataOutputStream out) throws IOException
integer - the BigInteger to writeout - the stream to write it toIOException - I/O exceptionpublic static BigInteger readBigInteger(DataInputStream dis) throws IOException
dis - the stream to read fromIOException - I/O exceptionpublic static String biToHex(BigInteger bi)
bi - a big integer.Copyright © 2016. All rights reserved.