读取16进制字符串

@param in {@link InputStream}
@param length 长度
@param toLowerCase true 传换成小写格式 ， false 传换成大写格式
@return 16进制字符串
@throws IORuntimeException IO异常
773237
public static String readHex(InputStream in, int length, boolean toLowerCase) throws IORuntimeException {
		return HexUtil.encodeHexStr(readBytes(in, length), toLowerCase);
	}
527438
public static final int getShort(InputStream is) throws IOException
   {
      byte[] data = new byte[2];
      is.read(data);
      return getShort(data, 0);
   }
1087503
public static byte[] readAllToBytes(final InputStream in) throws IOException {
    try {
      final ByteArrayOutputStream result = new ByteArrayOutputStream();
      final byte[] buffer = new byte[1024];
      int length;
      while ((length = in.read(buffer)) != -1) {
        result.write(buffer, 0, length);
      }
      return result.toByteArray();
    } finally {
      in.close();
    }
  }
915331
static public int unpackInt(InputStream in) throws IOException {
        int ret = 0;
        int v;
        do{
            v = in.read();
            if(v==-1)
                throw new EOFException();
            ret = (ret<<7 ) | (v & 0x7F);
        }while((v&0x80)==0);

        return ret;
    }
622522
public static long copy(InputStream in, OutputStream out, int bufferSize, StreamProgress streamProgress) throws IORuntimeException {
		Assert.notNull(in, "InputStream is null !");
		Assert.notNull(out, "OutputStream is null !");
		if (bufferSize <= 0) {
			bufferSize = DEFAULT_BUFFER_SIZE;
		}

		byte[] buffer = new byte[bufferSize];
		if (null != streamProgress) {
			streamProgress.start();
		}
		long size = 0;
		try {
			for (int readSize = -1; (readSize = in.read(buffer)) != EOF;) {
				out.write(buffer, 0, readSize);
				size += readSize;
				out.flush();
				if (null != streamProgress) {
					streamProgress.progress(size);
				}
			}
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
		if (null != streamProgress) {
			streamProgress.finish();
		}
		return size;
	}
32919
public int setBytes(int index, InputStream in, int length)
            throws IOException
    {
        checkIndexLength(index, length);
        byte[] bytes = new byte[4096];
        int remaining = length;
        while (remaining > 0) {
            int bytesRead = in.read(bytes, 0, Math.min(bytes.length, remaining));
            if (bytesRead < 0) {
                // if we didn't read anything return -1
                if (remaining == length) {
                    return -1;
                }
                break;
            }
            copyMemory(bytes, SizeOf.ARRAY_BYTE_BASE_OFFSET, base, address + index, bytesRead);
            remaining -= bytesRead;
            index += bytesRead;
        }
        return length - remaining;
    }
578562
protected int readFully(InputStream in, byte buffer[])
        throws java.io.IOException {
        for (int i = 0; i < buffer.length; i++) {
            int q = in.read();
            if (q == -1)
                return i;
            buffer[i] = (byte)q;
        }
        return buffer.length;
    }
1115286
private static int readFully(InputStream in, ByteArrayOutputStream bout,
            int length) throws IOException {
        int read = 0;
        byte[] buffer = new byte[2048];
        while (length > 0) {
            int n = in.read(buffer, 0, length<2048?length:2048);
            if (n <= 0) {
                break;
            }
            bout.write(buffer, 0, n);
            read += n;
            length -= n;
        }
        return read;
    }
413388
public int decode(final InputStream stream, final ByteBuffer buffer) throws IOException {
        if (reachedEOF) {
            return -1;
        }

        // TODO: Don't decode more than single runs, because some writers add pad bytes inside the stream...
        while (buffer.hasRemaining()) {
            int n;
            
            if (splitRun) {
                // Continue run
                n = leftOfRun;
                splitRun = false;
            }
            else {
                // Start new run
                int b = stream.read();
                if (b < 0) {
                    reachedEOF = true;
                    break;
                }
                n = (byte) b;
            }

            // Split run at or before max
            if (n >= 0 && n + 1 > buffer.remaining()) {
                leftOfRun = n;
                splitRun = true;
                break;
            }
            else if (n < 0 && -n + 1 > buffer.remaining()) {
                leftOfRun = n;
                splitRun = true;
                break;
            }

            try {
                if (n >= 0) {
                    // Copy next n + 1 bytes literally
                    readFully(stream, buffer, sample.length * (n + 1));
                }
                // Allow -128 for compatibility, see above
                else if (disableNoOp || n != -128) {
                    // Replicate the next byte -n + 1 times
                    for (int s = 0; s < sample.length; s++) {
                        sample[s] = readByte(stream);
                    }

                    for (int i = -n + 1; i > 0; i--) {
                        buffer.put(sample);
                    }
                }
                // else NOOP (-128)
            }
            catch (IndexOutOfBoundsException e) {
                throw new DecodeException("Error in PackBits decompression, data seems corrupt", e);
            }
        }

        return buffer.position();
    }
106353
public static byte[] readBytes(InputStream in) throws IORuntimeException {
		final FastByteArrayOutputStream out = new FastByteArrayOutputStream();
		copy(in, out);
		return out.toByteArray();
	}
107837
public static char littleChar(InputStream input) throws IOException {
        int lo = input.read();
        if (lo < 0) {
            throw new EOFException();
        }
        int hi = input.read();
        if (hi < 0) {
            throw new EOFException();
        }
        return (char)((hi << 8) | lo);
    }
310732
protected int readFully(InputStream in, byte buffer[], int offset, int len)
        throws java.io.IOException {
        for (int i = 0; i < len; i++) {
            int q = in.read();
            if (q == -1)
                return ((i == 0) ? -1 : i);
            buffer[i+offset] = (byte)q;
        }
        return len;
    }
370089
public int readInt(InputStream in) throws IOException {
        return ((byte) in.read() & 0xff) << 24
            | ((byte) in.read() & 0xff) << 16
            | ((byte) in.read() & 0xff) << 8
            | (byte) in.read() & 0xff;
    }
357546
public static final int readUTF(DataInput in,
                                    char[] chars, int offset, int length)
        throws IOException
    {
        if (length == 0) {
            return 0;
        }

        int c, c2, c3;

        int charCount = 0;
        while (charCount < length) {
            try {
                c = in.readByte() & 0xff;
            }
            catch (EOFException e) {
                break;
            }
            switch (c >> 4) {
            case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
                // 0xxxxxxx
                chars[offset + charCount++] = (char)c;
                break;
            case 12: case 13:
                // 110x xxxx  10xx xxxx
                c2 = in.readByte();
                if ((c2 & 0xc0) != 0x80) {
                    throw new UTFDataFormatException();
                }
                chars[offset + charCount++] =
                    (char)(((c & 0x1f) << 6) | (c2 & 0x3f));
                break;
            case 14:
                // 1110 xxxx  10xx xxxx  10xx xxxx
                c2 = in.readByte();
                c3 = in.readByte();
                if ((c2 & 0xc0) != 0x80 || (c3 & 0xc0) != 0x80) {
                    throw new UTFDataFormatException();
                }
                chars[offset + charCount++] = (char)(((c & 0x0f) << 12) |
                                                     ((c2 & 0x3f) << 6) |
                                                     (c3 & 0x3f));
                break;
            default:
                // 10xx xxxx,  1111 xxxx
                throw new UTFDataFormatException();
            }
        }

        return (charCount == 0) ? -1 : charCount;
    }
673250
public static long skip(final InputStream input, final long toSkip) throws UncheckedIOException {
        if (toSkip < 0) {
            throw new IllegalArgumentException("Skip count must be non-negative, actual: " + toSkip);
        } else if (toSkip == 0) {
            return 0;
        }

        final byte[] buf = Objectory.createByteArrayBuffer();
        long remain = toSkip;

        try {
            while (remain > 0) {
                long n = read(input, buf, 0, (int) Math.min(remain, buf.length));

                if (n < 0) { // EOF

                    break;
                }

                remain -= n;
            }

            return toSkip - remain;
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        } finally {
            Objectory.recycle(buf);
        }
    }
1189836
private static int readShortLength(DataInput in) throws IOException {
        int length = (in.readByte() & 0xFF) << 8;
        return length | (in.readByte() & 0xFF);
    }
130120
private static short readLEShort(InputStream in) throws IOException {
		short s = (byte)in.read();
		s |= (byte)in.read() << 8;
		return s;
	}