Friday, November 5, 2010

Code Snippet to Convert String to Hex-Decimal

A Small Code Snippet to Convert String to Hex-Decimal

class StringtoHexConvertion {

public static void main(String args[]){

try{
String imputString = "000000000002";
byte[] bytes = imputString .getBytes("US-ASCII");

String str1 = "";
for(int i=0;i
System.out.println("byte value = "+ bytes[i]);
str1 = str1 + Integer.toHexString(bytes[i]);
}
System.out.println(" final String = "+ str1);
}
catch(Exception e){}
}
}

It might be helpful for some sceneries.

2 comments:

  1. Incredible! This blog looks just like my old one!
    It's on a totally different subject but it has pretty much the same layout and design. Wonderful choice of colors!

    my web blog; devis fenetre pvc

    ReplyDelete