Changeset 6175 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2013-08-22T14:41:30+02:00 (13 years ago)
- File:
-
- 1 edited
-
trunk/src/org/openstreetmap/josm/tools/Utils.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Utils.java
r6123 r6175 401 401 } 402 402 403 private static final char[] HEX_ARRAY = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; 404 403 405 /** 404 406 * Converts a byte array to a string of hexadecimal characters. … … 409 411 */ 410 412 public static String toHexString(byte[] bytes) { 411 char[] hexArray = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; 412 char[] hexChars = new char[bytes.length * 2]; 413 for (int j=0; j<bytes.length; j++) { 414 int v = bytes[j] & 0xFF; 415 hexChars[j*2] = hexArray[v/16]; 416 hexChars[j*2 + 1] = hexArray[v%16]; 413 414 if (bytes == null) { 415 return ""; 416 } 417 418 final int len = bytes.length; 419 if (len == 0) { 420 return ""; 421 } 422 423 char[] hexChars = new char[len * 2]; 424 for (int i = 0, j = 0; i < len; i++) { 425 final int v = bytes[i]; 426 hexChars[j++] = HEX_ARRAY[(v & 0xf0) >> 4]; 427 hexChars[j++] = HEX_ARRAY[v & 0xf]; 417 428 } 418 429 return new String(hexChars);
Note:
See TracChangeset
for help on using the changeset viewer.
