0

I have the below bytes:

byte[] data = {(byte) 0x91,(byte) 0x92,(byte) 0x93,(byte) 0x94,(byte) 0x95,
               (byte) 0x96,(byte) 0x97,(byte) 0x98,(byte) 0x99,
               0x0A,0x0A,0x0A,0x0A,0x0A};

I want to make a loop in order to make dialogs with byte contents:

(byte) 0x91
(byte) 0x92
(byte) 0x93 

and so on.

Mat
  • 202,337
  • 40
  • 393
  • 406
kosbou
  • 3,919
  • 8
  • 31
  • 36
  • 6
    What is your problem? Writing the loop? Creating the dialogs? Getting the string representation of bytes? – assylias Sep 09 '12 at 19:54
  • I am java novice how to get string represantation of byte – kosbou Sep 09 '12 at 19:55
  • Try String.format . – Vance Maverick Sep 09 '12 at 19:56
  • search a bit, there are plenty of other similar questions: http://stackoverflow.com/questions/332079/in-java-how-do-i-convert-a-byte-array-to-a-string-of-hex-digits-while-keeping-l ; www.rgagnon.com/javadetails/java-0596.html ; – Augusto Sep 09 '12 at 19:59
  • possible duplicate of [Convert from byte array to hex string in java](http://stackoverflow.com/questions/9655181/convert-from-byte-array-to-hex-string-in-java) – Augusto Sep 09 '12 at 20:00

1 Answers1

0

If you want a String representation in loop, here's something you can try:

for(int index = 0; index < data.length){
    System.out.println(String.format("%02X", data[index));
}
Sujay
  • 6,753
  • 2
  • 30
  • 49