Häufige Werkzeuge-ähnliche Methoden zur Verarbeitung von Bytes dienen Ihrer Referenz. Der spezifische Inhalt ist wie folgt
Paket com.demo.utils; import Java.io.BytearrayInputStream; Import Java.io.BytearrayoutputStream; Import Java.io.ioException Java.io.objectInputStream; ImportStream importieren Java.io. bytes* @author dongyangyang * @Date 2017/3/13 12:31 * @Version 1.0 * */public class ByteUtils { /** * The value table that needs to be associated with when constructing a new byte*/ private static final byte[] BUILD_BYTE_TABLE = new byte[] { (byte) 128, (byte) 64, (byte) 32, (byte) 16, (Byte) 8, (Byte) 4, (Byte) 2, (Byte) 1}; private byteutils () {} /** * Kurzer Konvertieren in Byte -Array * * @param number * Daten zu konvertieren. * @return konvertiertes Byte -Array. */ public static byte [] ShortTobyte (Kurznummer) {Byte [] B = New Byte [2]; für (int i = 1; i> = 0; i--) {b [i] = (byte) (Zahl % 256); Nummer >> = 8; } return b; } /*** Byte in kurze Konvertierung** @param b* Short Byte Array* @return Short Value. */ public static Short Bytetoshort (byte [] b) {return (kurz) ((((b [0] & 0xff) << 8) | B [1] & 0xff);}/ ** * Integer Conversion in Byte Array * * @param number * skew daten. B = neuer Byte [4] für (int i = 3; i> = 0; i--) {b [i] = (Byte) (Nummer % 256) {return (((((b [0] & 0xff) << 24) | ((b [1] & 0xff) << 16) | ((b [2] & 0xff) << 8) | (b [3] & 0xff)); LongTobyte (lange Zahl) {Byte [] B = neuer Byte [8]; bytetolong (byte [] b) {return (((lang) b [0] & 0xff) << 56) | (((lang) b [1] & 0xff) << 48) | (((lang) b [2] & 0xff) << 40) | ((lang) b [3] & 0xff) << 32) | ((lang) B [5] & 0xff) << 16) | d) {Byte [] Bytes = neues Byte [8]; Doppelte Präzisions -Byte -Array (lang) b [3] << 24); (lang) b [7] << 56); Float.Floattointbits (d); public float bytetofloat (byte [] b) {int l; Float.intbitstofLOAT (L); String * @param B * Byte -Array durch Zeichenfolgen durch angegebene Codierung. Byte -Array von Objektinstanzen. out.close (); BytearrayInputstream (b); Gleiches hat mindestens ein Bit, das nicht gleich ist. Byte Array. A.Length; BitString (Byte B) {StringBuilder Buff = New StringBuilder (); Array. >> i) & 1) == 1; BytebitValue (Byte B, int Index) {BytetObitarray (B) [Index]; {Byte B = 0; 7 werfen eine Ausnahme von Bounds. * @Param. / ** * Die angegebene IP -Adresse in eine Byte -Darstellung in der IP -Array nicht mehr als 255 sein. address.Length ()> 15) {Neue IllegalArgumentException ("Ungültige IP -Adresse"); point = 0; // Die Zahl der aktuelle Operation beträgt bis zu 3. Curr CurrentChar; Buff.Length () - (i+1)> 0) {Neue IllegalArgumentException ("Ungültige IP -Adresse"); Integer.ParseInt (number.toString ()); (pointnum & 0xff); Das obige ist der gesamte Inhalt dieses Artikels. Ich hoffe, es wird für das Lernen aller hilfreich sein und ich hoffe, jeder wird Wulin.com mehr unterstützen.