Search
 
SCRIPT & CODE EXAMPLE
 

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);
   }
}
Comment

hexstring to string In java

import java.util.Scanner;
public class HexadecimalToString {
   public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter a Hexadecimal value: ");
      String str = sc.next();
      String result = new String();
      char[] charArray = str.toCharArray();
      for(int i = 0; i < charArray.length; i=i+2) {
         String st = ""+charArray[i]+""+charArray[i+1];
         char ch = (char)Integer.parseInt(st, 16);
         result = result + ch;
      }
      System.out.println(result);
   }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java list of arrays 
Java :: java memory increase command 
Java :: reverseString 
Java :: java list select field 
Java :: java fot 
Java :: install java using cmd 
Java :: jtable font size 
Java :: what is maven artifact 
Java :: Iterator to list (Java) 
Java :: 2d array java 
Java :: set top corner of shape radius programmatically android 
Java :: json array get json object 
Java :: How to get the nth Fibonacci number code in Java using recursion 
Java :: java time 
Java :: how to convert kilometers to miles in java 
Java :: how to turna date into a LocalDateTime java 
Java :: in java how to compare two strings 
Java :: rainbow six 
Java :: multiple condition inside for loop java 
Java :: java netbeans textfield only numbers 
Java :: check if field exists in java 
Java :: convert arraylist to array int 
Java :: how to convert line into string java 
Java :: how to create an array without knowing the size java 
Java :: java sort a map by keys 
Java :: Syntax of how to create ArrayList in Java 
Java :: How to sort 2d array in java using stream api 
Java :: launch java batch 
Java :: java ints to color int 
Java :: java asynchronous programming example 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =