×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    27

    howto convert byte array to string???

    hi all,

    I want to exchange APDUs between the Nokia Phone and a Smart Card.

    I use this code:
    byte[] response = smc.exchangeData(APDU);

    now I want to react to the response. (for now it would be enough to show it on screen in hex form!!)

    I tried these two code options:
    1)
    form.append(response.toString()+"\n");
    2)
    String string = new String(response);
    form.append(string);

    both didn´t work the way i want it to.

    For later I also want to use an if statement like: if (response == {(byte) 0x00,(byte) 0x00}) {}


    Can somebody tell how to convert the data??

    -Thanx

  2. #2
    Registered User
    Join Date
    Apr 2007
    Posts
    6

    Re: howto convert byte array to string???

    I write myself this function which works good:

    public String ByteToString(byte[] b){
    String t="";
    for(int i=0;i<b.length;i++) t=t+(char)b[i];
    return t;
    }

  3. #3
    Registered User
    Join Date
    Jun 2007
    Posts
    27

    Re: howto convert byte array to string???

    Thanx for the response!!

    I have one more question about byte arrays:
    how do I concatenate two byte arrays (like: byte[] a = byte[] b + byte[] c)??

    On the Internet I came across the methods concat() and concatenate(), but Eclipse says that it doesn´t know them and that it couldn´t resolve them.

    How do you guys do it??

    -Thanx

  4. #4
    Regular Contributor
    Join Date
    May 2007
    Posts
    63

    Re: howto convert byte array to string???

    Covert Byte Array to String
    -String(byte[] bytes, int offset, int length)
    http://java.sun.com/j2se/1.4.2/docs/...ng/String.html

    Concat Byte
    -Declear a byte array with the total size. Throw into the new byte array

Similar Threads

  1. what is an APDU
    By pawangjain in forum Near Field Communication
    Replies: 0
    Last Post: 2007-07-02, 07:42
  2. saving unsigned bytes in byte array
    By nicenouman in forum Mobile Java General
    Replies: 3
    Last Post: 2006-10-05, 10:26
  3. Convert wav to byte array?
    By SpaceCowboy in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2006-09-04, 09:25
  4. How to Convert mid to byte array?
    By returnti in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2003-05-09, 18:23
  5. Loading images from byte array on 6130i
    By enlightment in forum Mobile Java General
    Replies: 2
    Last Post: 2002-06-05, 19:44

Posting Permissions

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