Thread: How Do I turn A Sentance Into Bytes?

Results 1 to 4 of 4
  1. #1 How Do I turn A Sentance Into Bytes? 
    Registered Member
    Join Date
    Feb 2009
    Posts
    43
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    I Want To Turn

    "Are you sure you want to make this trade?"

    Into Bytes.

    Ex. 34,325,205,230,213.
    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    Jan 2008
    Posts
    2,345
    Thanks given
    20
    Thanks received
    575
    Rep Power
    1202
    First of all, it's called a 'string', not a 'sentance'.

    Second, learn to freaking spell 'sentence'.

    Third... this is how to convert string to bytes.

    Code:
            String stringVar = "Lmfao this string dat Michael just made owns you.";
            byte[] theByteArray = stringVar.getBytes();
    Then i guess you can just use the print method to see what the byte was.
    Code:
            System.out.println(theByteArray.length);
    Reply With Quote  
     

  3. #3  
    Programmer, Contributor, RM and Veteran




    Join Date
    Mar 2007
    Posts
    5,074
    Thanks given
    2,625
    Thanks received
    3,579
    Discord
    View profile
    Rep Power
    5000
    Quote Originally Posted by Lil_Michael View Post
    Then i guess you can just use the print method to see what the byte was.
    Code:

    System.out.println(theByteArray.length);
    That just returns the length of the array, you want:

    System.out.println(new String(theByteArray));

    Or to find out what the byte are:

    for(byte b : theByteArray) {
    System.out.println(b);
    }
    .
    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Jan 2008
    Posts
    2,345
    Thanks given
    20
    Thanks received
    575
    Rep Power
    1202
    Quote Originally Posted by Graham View Post
    That just returns the length of the array, you want:

    System.out.println(new String(theByteArray));

    Or to find out what the byte are:

    for(byte b : theByteArray) {
    System.out.println(b);
    }
    Didn't exactly know.

    I don't use bytes for strings.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •