![JAR search and dependency download from the Maven repository](/logo.png)
com.github.andyshao.util.ByteBuffereTools Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Useful-Tools Show documentation
Show all versions of Useful-Tools Show documentation
Some thing about the useful tools of the JDK 1.8.
package com.github.andyshao.util;
import java.nio.ByteBuffer;
import com.github.andyshao.convert.Convert;
/**
*
* Descript:
* Copyright: Copyright(c) Aug 4, 2014
* Encoding:UNIX UTF-8
*
* @author Andy.Shao
*
*/
public final class ByteBuffereTools {
@Deprecated
public static String byte2Hex(byte[] bs) {
StringBuilder builder = new StringBuilder();
for (byte b : bs) {
builder.append(Convert.BYTE_2_HEX.convert(b));
}
return builder.toString();
}
/**
* Only return a space which great than buffer.position() and less than
* buffer.limit()
*
* @param buffer the buffer which has the info
* @return return the byte array and the info in it
*/
public static byte[] usedArray(ByteBuffer buffer) {
return ArrayTools.splitArray(buffer.array() , buffer.position() , buffer.limit());
}
private ByteBuffereTools() {
throw new AssertionError("No support instance " + ByteBuffereTools.class.getName());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy