Java Convert Octal String to Byte

Tags: Octal byte

In this Java core tutorial we learn how to convert an octal String value into a byte value in Java programming language.

How to convert octal to byte in Java

In Java, with a given String in octal number format we can use the Byte.decode(String nm) static method to convert it to a byte value as the following example Java code.

ConvertOctalToByteExample.java

public class ConvertOctalToByteExample {
    public static void main(String... args) {
        String octalString = "014";

        // Convert Octal String to Byte
        byte byteValue = Byte.decode(octalString);

        System.out.println("Octal value: " + octalString);
        System.out.println("byte value: " + byteValue);
    }
}
The output as below.
Octal value: 014
byte value: 12

Happy Coding 😊

Java Convert Byte to Hexadecimal String

Java Convert Hexadecimal String to Byte

Java Convert Byte to Octal String

Java Convert Byte to BigDecimal

Java Convert Byte to BigInteger