conversions

Discussion in 'Java' started by A n A n D, Apr 21, 2004.

  1. A n A n D

    A n A n D Guest

    Hi,
    How to convert character into bytes and then back to char ?
    I know there is a method ..
    public static byte [] charToByteArray( char c ) {

    byte [] twoBytes = { (byte)(c & 0xff), (byte)(c >> 8 & 0xff) };

    return twoBytes;

    }

    to convert to bytes. But how can I convert raw bytes back to char.

    ALso, how can I do this for int and short as well.

    Thanks.

    --Anand
    A n A n D, Apr 21, 2004
    #1
    1. Advertising

  2. A n A n D

    Roedy Green Guest

    On Wed, 21 Apr 2004 03:33:22 GMT, "A n A n D" <> wrote
    or quoted :

    >How to convert character into bytes and then back to char ?


    see http://mindprod.com/jgloss/converter.html for all your conversion
    needs. I had a fan phone call today for that little Applet.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Apr 21, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Max

    conversions

    Max, Sep 11, 2003, in forum: VHDL
    Replies:
    0
    Views:
    575
  2. Weaam Attallah

    Type Conversions

    Weaam Attallah, Nov 18, 2003, in forum: VHDL
    Replies:
    1
    Views:
    1,419
    Paul Uiterlinden
    Nov 18, 2003
  3. Brian Henry

    Access db to ado.net data type conversions?

    Brian Henry, Oct 8, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    2,623
    Paul Clement
    Oct 13, 2003
  4. Paul King

    XML conversions

    Paul King, Aug 12, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    306
    Paul King
    Aug 12, 2004
  5. Replies:
    10
    Views:
    697
    Jasen Betts
    Aug 5, 2005
Loading...

Share This Page