🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #16055

Re: Hexadecimal string to string

#16055
From: Omer Azhar Qureshi
Date: Wed, 31 Mar 1999 00:00
53 lines
1742 bytes
Yolanda,
heres some code that i typed out just for u...... ;)

class Conversion
{
 public static void main (String args [])
   {
      String CharString;
      String HexString;

      HexString = String2Hex ("ABCD");
      CharString = Hex2String (HexString);

      System.out.println (HexString);  // Displays 41424344
      System.out.println (CharString); // Displays ABCD
   }

   public static String String2Hex (String CharString)
   {
    String HexString = "";
      char cChar;
      int iNumber;

      for (int iIndex = 0; iIndex < CharString.length (); ++iIndex)
      {
       cChar = CharString.charAt(iIndex);
         iNumber = (int) cChar;
         HexString += Integer.toHexString(iNumber);
      }

      return HexString;
   }

   public static String Hex2String (String HexString)
   {
  String CharString = "";
      char cChar;
      int iNumber;

      for (int iIndex = 0; iIndex < HexString.length (); iIndex += 2)
      {
         iNumber = Integer.parseInt (HexString.substring (iIndex, iIndex +
2), 16);
         CharString += new Character((char)iNumber).toString();
      }

      return CharString;
   }
}


hope this is what u wanted.... :)
Oaq
Technical Details
Message-ID: <7dt0eu$bdk12@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7doad4$7fo14@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,b25984f20866b948
X-Google-Attributes: gidf74b3,public
From: "Omer Azhar Qureshi" <oaq@systemeltd.com.pk>
Subject: Re: Hexadecimal string to string
Date: 1999/03/31
Message-ID: <7dt0eu$bdk12@forums.borland.com>
X-Deja-AN: 461128264
References: <7doad4$7fo14@forums.borland.com>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.language