java convert bytes to string
byte[] bytes = "hello".getBytes();
String s = new String(bytes, StandardCharsets.UTF_8);
java convert bytes to string
byte[] bytes = "hello".getBytes();
String s = new String(bytes, StandardCharsets.UTF_8);
String to hexadecimal in java
// String to hexadecimal in java
import java.util.Scanner;
public class StringToHexJava
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Please enter a string: ");
String strInput = sc.next();
StringBuffer sb = new StringBuffer();
char[] chArray = strInput.toCharArray();
for(int a = 0; a < chArray.length; a++)
{
String strHexadecimal = Integer.toHexString(chArray[a]);
sb.append(strHexadecimal);
}
String strOutput = sb.toString();
System.out.println(strOutput);
sc.close();
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us