Try something like this:
  (*Chris*)

/**
 * Junk
 *
 * $ID$
 *
 * @author Chris Pratt
 * @version $Revision$
 *
 * 6/21/01
 */

public class Junk {

  /**
   * Return the ordinal number of the character provided
   *
   * @param c One of (0 - 9, A - F, a - f)
   * @return An integer between 0 and 15
   */
  public static int ord (char c) {
    if(c <= '9') {
      return ((int)c) - ((int)'0');
    } else if(c <= 'F') {
      return ((int)c) - ((int)'A') + 10;
    } else {
      return ((int)c) - ((int)'a') + 10;
    }
  } //ord

  /**
   * Convert a Hexidecimal String into a Character String
   *
   * @param str A String of Hexidecimal Characters
   * @return A String
   */
  public static String convert (String str) {
    if(str != null) {
      char[] in = str.toCharArray();
      StringBuffer buf = new StringBuffer(in.length / 2);
      int i = 0;
      while(i < in.length) {
        buf.append((char)((ord(in[i++]) << 4) | ord(in[i++])));
      }
      return buf.toString();
    }
    return null;
  } //convert

  /**
   * Program Entry-point
   *
   * @param args Command Line Arguments
   */
  public static void main (String[] args) {
    System.out.println(convert(args[0]));
  } //main

} //*Junk


----- Original Message -----
From: "Sushil Singh" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 20, 2001 10:16 PM
Subject: [JSP-INTEREST] Hexadecimal to String


> Hi,
>
> Is it possible to convert hexadecimal value into String in java, is
> there any class/funcion is available?
>
> For ex:
> 546F6F6C73206F6620746865205472616465
> is equivalent to "Tools of the Trade"
>
> Thanks in advance.
>
> Sushil
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to