SEC-1764: Remove use of Java 6 method Arrays.copyOfRange.

This commit is contained in:
Luke Taylor 2011-06-15 11:22:17 +01:00
parent 571bfc4869
commit 89b7b2b935
1 changed files with 3 additions and 1 deletions

View File

@ -22,8 +22,10 @@ public final class Utf8 {
public static byte[] encode(CharSequence string) {
try {
ByteBuffer bytes = CHARSET.newEncoder().encode(CharBuffer.wrap(string));
byte[] bytesCopy = new byte[bytes.limit()];
System.arraycopy(bytes.array(), 0, bytesCopy, 0, bytes.limit());
return Arrays.copyOfRange(bytes.array(), 0, bytes.limit());
return bytesCopy;
} catch (CharacterCodingException e) {
throw new IllegalArgumentException("Encoding failed", e);
}