Java - Byte

Java Conceptuel Diagram

Java - Byte


Byte (Bit Octet) - Computer storage Unit (8bit) in Java




from Number - Hexadecimal notation (0x)

0xFF = 1111 1111

byte[] bytes = new byte[] { 
                (byte) 0x01, (byte) 0xFF, (byte) 0x2E, (byte) 0x6E, (byte) 0x30


A byte is also an integer between 0 (0000 0000) and 255 (1111 1111)

byte[] bytes = new byte[] { -1, -128, 1, 127 };

From File


From String

String s = "Hello Nico";
byte[] bytes = str.getBytes(StandardCharsets.UTF_8);


Array To String

Byte array to Java - String

byte[] bytes = { 'N', 'i', 'c', 'o' };
String s = new String(bytes);

String to Array

String s = "Hello Nico";
byte[] bytes = str.getBytes(StandardCharsets.UTF_8);

To Hexa

byte[] bytes = {'N', 'i', 'c', 'o'};
for (byte b : bytes) {
    String s = String.format("%02X", b);



To int

byte b = 0x1
int i = Byte.toUnsignedInt(b)

Byte byte = new Byte(1);
int i = byte.intValue();

Discover More
Java Conceptuel Diagram
Java - (Primitive|Native) Data Type

Java has a fixed set of primitive types: boolean, byte, short, int, long, char, float, and double. They can also be used in a wrapper class in order to enhance the functionalities....
Simple Class
Java - Class (Definition)

A java/lang/Classclass provides the blueprint for objects; you create an object from a class. All classes are derived from the Object class. A class declaration names the class and encloses the class...
Java Conceptuel Diagram
Java - IO - Byte Stream

Byte I/O Operations (Stream) in java Programs use byte streams to perform input and output of 8-bit bytes. All byte stream classes are descended from this two class: input stream to read byte or...
Java Conceptuel Diagram
Java - String

in Java. Class: java/lang/String from a A java/io/StringWriterStringWriter is A character stream that collects its output in a string buffer, which can then be used to construct a string....

Share this page:
Follow us:
Task Runner