Answers for "string byte array to byte array java"

1

java byte array to string

// string to byte[]
  byte[] bytes = "hello".getBytes(StandardCharsets.UTF_8);

  // byte[] to string
  String s = new String(bytes, StandardCharsets.UTF_8);
Posted by: Guest on January-24-2022
1

String to Byte array Java

import java.util.Arrays;

public class StringToByte {
 public static void main(String[] args) {
  String str = "Example String";
  byte[] b = str.getBytes();
  System.out.println("Array " + b);
  System.out.println("Array as String" + Arrays.toString(b));
 }
}
Posted by: Guest on April-15-2022

Code answers related to "string byte array to byte array java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language