1 package com.google.common.jdk5backport;
2 
3 /**
4  * An Arrays alternative containing JDK 1.6 method equivalents used
5  * to support JDK 1.5 with a few pass-through methods to reduce import
6  * conflicts.
7  */
8 public final class Arrays {
copyOf(byte[] original, int newLength)9   public static byte[] copyOf(byte[] original, int newLength) {
10     return copyOfRange(original, 0, newLength);
11   }
12 
copyOfRange(byte[] original, int from, int to)13   public static byte[] copyOfRange(byte[] original, int from, int to) {
14     int newLength = to - from;
15     if (newLength >= 0) {
16       byte[] copy = new byte[newLength];
17       System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength));
18       return copy;
19     }
20     throw new IllegalArgumentException();
21   }
22 
fill(byte[] array, byte val)23   public static void fill(byte[] array, byte val) {
24     java.util.Arrays.fill(array, val);
25   }
26 
equals(byte[] a, byte[] a2)27   public static boolean equals(byte[] a, byte[] a2) {
28      return java.util.Arrays.equals(a, a2);
29   }
30 }
31