바이트 처리를위한 일반적인 도구와 같은 방법은 참조 용입니다. 특정 내용은 다음과 같습니다
package com.demo.utils; import java.io.bytearrayinputStream; import java.io.bytearrayoutputStream; import java.io.ioexception; import java.io.objectinputstream; import java.io.objectOutputStream; import java.nio.charset.char java./** java. BYTES * @Author Dongyangyang * @date 2017/3/13 12:31 * @version 1.0 */public class byteutils {/** * 새 바이트 */private static final byte [] build_byte_table [] 128, (byte) 34, (byte) 34, (byte) 34, (바이트) 16, (바이트) 8, (바이트) 4, (바이트) 2, (바이트) 1}; Private ByTeUtils () {} /** * 짧은 바이트 배열로 변환 * @param 번호 * 변환 할 데이터. * @return 바이트 배열 변환. */ public static byte [] shortobyte (짧은 숫자) {byte [] b = new Byte [2]; for (int i = 1; i> = 0; i-) {b [i] = (byte) (숫자 % 256); 숫자 >> = 8; } 반환 b; } /*** 바이트 ~ 짧은 변환** @param b* 짧은 바이트 배열* @return 짧은 값. */ public static short bytetothort (byte [] b) {return (short) (((((b [0] & 0xff) << 8) | b [1] & 0xff)));}/ ** * 정수 변환 * * @param 번호 * @param 번호 * @Return BYTE {/ public static byte [] inttobyte (inttobyte). BYTE [4] bytetoint (byte [] b) {return ((((B [0] & 0xff) << 24) | ((B [0] & 0xff) << 24) << 16) | ((b [2] & 0xff) << 8) | (b [3] & 0xff)); 형성 긴 수술 데이터. */ public static long bytetolong (byte [] b) {return (((long) b [0] & 0xff) << 56) | (((long) b [1] & 0xff) << 48) | ((long) b [2] & 0xff) << 40) | ((Long) b [3] & 0xff) <3) 3). << 24) ((Long) & 0xff) | Doubletobyte (double d) {bytes = new byte [8]; @param b * 이중 정밀한 부동산 지점 (byte) 0xffffff; 0xffffffffffffl; L | = (Long) << 56; BYTE [4] int i = 0; i <bytes. valueof (l). @ByteTofloat (byte) 0xffffffl; intbitstofloat. * @param byte 배열은 지정된 인코딩 * @param charstring에 의해 변환됩니다. @객체 인스턴스의 해당 바이트 배열 */ Public STACT BYTE (Object OBJ)는 {bytearRayoutputStream BUFF = 새로운 대상 퇴직자 (buff.write out); buff.tobytearray (); ClassFoundException {BytearrayinputStream (b) bde * @return 진실은 두 바이트의 각 비트는 동일합니다. 두 바이트가 동일합니다 | {return false} a.length; @비트 비트로 구성되어 있습니다. * 주어진 바이트를 계산하고 부울 배열은 0으로 표현됩니다. * @param b * byte > I Index ++] = (B >>> i) == 1; @비트의 값은 지정되어 있습니다. * / public static bytebitvalue (byte b, int index) {bytetobitarray (b) [index]; * / public byte buildnewbyte (byte b = 0; int i = 0; values [i]) {build_byte_table [i]} * reture reture represent 1, repractes 1, jectents 0, * @Param NewValue * @Param NewValue */ Public Byte Byte Byte (Byte vitean) NewValue; Bucknewbyte (Bitvalues) = null || length () <0 || stringBuilder (); If가 잘못된 IP를 나타냅니다 {currentChar)} ipnums 불법적 인 IPBUFF [I] = (PointNum & 0xff); 위는이 기사의 모든 내용입니다. 모든 사람의 학습에 도움이되기를 바랍니다. 모든 사람이 wulin.com을 더 지원하기를 바랍니다.