Java Convert Octal String to 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);
}
}
Octal value: 014
byte value: 12
Happy Coding 😊
Related Articles
Java Convert Byte to Hexadecimal String
Java Convert Hexadecimal String to Byte
Java Convert Byte to Octal String