Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

string to hexstring In java

import java.util.Scanner;
public class StringToHexadecimal {
   public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter a String value: ");
      String str = sc.next();
      StringBuffer sb = new StringBuffer();
      //Converting string to character array
      char ch[] = str.toCharArray();
      for(int i = 0; i < ch.length; i++) {
         String hexString = Integer.toHexString(ch[i]);
         sb.append(hexString);
      }
      String result = sb.toString();
      System.out.println(result);
   }
}
Source by www.tutorialspoint.com #
 
PREVIOUS NEXT
Tagged: #string #hexstring #In #java
ADD COMMENT
Topic
Name
8+3 =