Results 1 to 4 of 4

Thread: Need help

  1. #1
    newToJava2 is offline Member
    Join Date
    Sep 2010
    Posts
    1
    Rep Power
    0

    Default Need help

    I have String stringName = "1010005100";
    How do i conver that string to byte array, Unsigned Integer ( size 8 ).
    The resul should be "0x00, 0x00, 0x00, 0x00, 0x3c, 0x33, 0x74, 0x6c"

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,266
    Rep Power
    25

    Default

    Can you explain what the String represents? Is is a decimal number?
    If so use one of the Long class methods to convert it to an long value.
    Then use the AND operator (with 0xFF mask) and shifts to get each byte of the long into the byte array.

  3. #3
    gafa's Avatar
    gafa is offline Senior Member
    Join Date
    Jun 2010
    Posts
    107
    Rep Power
    0

    Default

    I guess this may help

    String stringName = "1010005100";
    byte [] array=stringName.getBytes();
    + 1 my REP
    Good Luck :)

  4. #4
    weakInjava is offline Member
    Join Date
    Sep 2010
    Location
    phillipines
    Posts
    2
    Rep Power
    0

    Default

    ahm could i make a request please?...if you reply to those problems would you also include a small overview to the program code or simply explain the thought to be understand easily...thanks....:) hope to learn more about java..

Posting Permissions

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