com.acgist.snail.utils.ByteUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snail Show documentation
Show all versions of snail Show documentation
基于Java开发的下载工具,支持下载协议:BT(BitTorrent、磁力链接、种子文件)、HLS(M3U8)、FTP、HTTP。
package com.acgist.snail.utils;
import java.nio.ByteBuffer;
/**
* 字符工具
*
* @author acgist
*/
public final class ByteUtils {
private ByteUtils() {
}
/**
* 读取剩余字节数据
*
* @param buffer 缓冲数据
*
* @return 剩余字节数据
*/
public static final byte[] remainingToBytes(ByteBuffer buffer) {
final byte[] bytes = new byte[buffer.remaining()];
buffer.get(bytes);
return bytes;
}
/**
* 读取剩余字节数据转为字符串
*
* @param buffer 缓冲数据
*
* @return 剩余字节数据字符串
*/
public static final String remainingToString(ByteBuffer buffer) {
return new String(remainingToBytes(buffer));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy