Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ASCII code to string

807591Apr 4 2008 — edited Apr 4 2008
Hi.
I've been searching a lot about this, and I've only seen methods to get a character from his ASCII code, but I want to get a String from his ascii code.
I mean, if I have the int (or long) 104101108108111 this is the String "hello".

If I have a Character, it's very simple: int i = 64; String end = (char) i;

I've tried to do this:
String end = "";
        Long b = new Long("104101108108111");
        byte[] c = b.toString().getBytes("US-ASCII");
        for(Byte d: c)
            end += c.toString();
        
        return end;
    }
But it returns something strange
Thnsk you very much
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 2 2008
Added on Apr 4 2008
11 comments
903 views