From 7700694a84284f6cdd301d69d0e8dbca3a31753c Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Tue, 9 Apr 2013 19:25:07 +0200 Subject: [PATCH] [New] add new method ArraysHelper.copyOf(byte[]) --- .../eitchnet/utils/helper/ArraysHelper.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/eitchnet/utils/helper/ArraysHelper.java b/src/main/java/ch/eitchnet/utils/helper/ArraysHelper.java index c54ac3e58..74a22a8cf 100644 --- a/src/main/java/ch/eitchnet/utils/helper/ArraysHelper.java +++ b/src/main/java/ch/eitchnet/utils/helper/ArraysHelper.java @@ -21,18 +21,41 @@ */ package ch.eitchnet.utils.helper; +import java.util.Arrays; + /** * @author Robert von Burg * */ public class ArraysHelper { + /** + * Returns true if the byte array contains the given byte value + * + * @param bytes + * the array to search in + * @param searchByte + * the value to search for + * + * @return true if found, false if not + */ public static boolean contains(byte[] bytes, byte searchByte) { for (byte b : bytes) { if (b == searchByte) return true; } - return false; } + + /** + * Creates a simple copy of the given array + * + * @param bytes + * the array to copy + * + * @return the copy + */ + public static byte[] copyOf(byte[] bytes) { + return Arrays.copyOf(bytes, bytes.length); + } }