Permalink
Browse files

implement Arrays.toString(byte[])

  • Loading branch information...
1 parent 248ff91 commit 852d77d0b5c63cd93b480ebb52d35fdddf0b14e9 @dicej dicej committed Aug 4, 2012
Showing with 17 additions and 0 deletions.
  1. +17 −0 classpath/java/util/Arrays.java
View
17 classpath/java/util/Arrays.java
@@ -17,6 +17,23 @@ public static String toString(Object[] a) {
return asList(a).toString();
}
+ public static String toString(byte[] a) {
+ if (a == null) {
+ return "null";
+ } else {
+ StringBuilder sb = new StringBuilder();
+ sb.append("[");
+ for (int i = 0; i < a.length; ++i) {
+ sb.append(String.valueOf(a[i]));
+ if (i + 1 != a.length) {
+ sb.append(", ");
+ }
+ }
+ sb.append("]");
+ return sb.toString();
+ }
+ }
+
private static boolean equal(Object a, Object b) {
return (a == null && b == null) || (a != null && a.equals(b));
}

0 comments on commit 852d77d

Please sign in to comment.