Hi

I am sure the following is not the correct solution but can be treated as a work-around.

 

             From the String "0x736D616C6C6170754069782E6E6574636F6D2E636F6D", read every byte as follows:

                                    0x73

0x6D

0x61

and so on.

 

            Type cast every byte to char as follows:

                        (char)    0x73                              

(char)    0x6D

(char)    0x61

and so on.

 

     Keep appending to a string buffer the result of the type casting and the final string from the string buffer is what you expect?

 

Regards

Balak

 

 

-----Original Message-----
From: ssmtech [mailto:[EMAIL PROTECTED]]
Sent:
Friday, November 08, 2002 5:59 PM
To: [EMAIL PROTECTED]
Subject: Converting a String containing Hexadecimal values to proper format String

 

Hello All,
          I am working on Oracle9i and accessing a PL/SQP Procedure through Java(EJB) ,that is returning me some Strings.The problem i am facing is ,i have a String called "EmailAddresses" which the Package is returning me a Hexadecimal Value instead of returning a String value.

 

For e.g. instead of returning say, an email address [EMAIL PROTECTED], it returns as one big string the HEX equivalent of each character in '[EMAIL PROTECTED]'.  It returns "0x736D616C6C6170754069782E6E6574636F6D2E636F6D".

 

The first 0x denotes that what follows is in HEX format.73 is the hex equivalent of letter 's', 6D is hex equivalent of letter 'm' and so on.

 

the Code is,
<code>

 


p1arr = (ARRAY) cstmt.getArray(13);
p1obj = (String[])p1arr.getArray();

 

int ElementCount = cstmt.getInt(14);

 

ArrayList addresses = new ArrayList();
for(int i=0;i<ElementCount;i++)
{
 addresses.add(p1obj[i]);
 System.out.println("The Email Addresses in the Arraylist is****** :"+addresses);
}

 

</code>

 

The SOP prints out the contents of Arraylist in Hexadecimal Format instead of String Format....

 

How do i get the Proper Format of Strings instead of getting it in Hexadecimal format.....
Is there a way i can convert a String Containing Hex Formated String into a proper String...

 

For e.g
I want to get,
 String emailAddresses = "[EMAIL PROTECTED]"
instead of
 String emailAddresses = "0x736D616C6C6170754069782E6E6574636F6D2E636F6D";

 

I will be having hundereds of such EmailAddresses which will contain Hexadecimal values....how do i go about converting all of them to proper format Strings....

 

Can anybody please help me out with this problem...Any suggestions or code will be greatly appreciated...
Thanks in advance

 

Regards
Sam

Reply via email to