Here you can find the source of blockCopy(ByteBuffer source, int srcOffset, byte[] dest, int destOffset, int count)
public static boolean blockCopy(ByteBuffer source, int srcOffset, byte[] dest, int destOffset, int count)
//package com.java2s; /* ************************************************************************ # # DivConq/*from w ww . j ava2 s .co m*/ # # http://divconq.com/ # # Copyright: # Copyright 2014 eTimeline, LLC. All rights reserved. # # License: # See the license.txt file in the project's top-level directory for details. # # Authors: # * Andy White # ************************************************************************ */ import java.nio.ByteBuffer; public class Main { public static boolean blockCopy(byte[] source, int srcOffset, byte[] dest, int destOffset, int count) { if ((source == null) || (dest == null)) return false; if ((srcOffset < 0) || (destOffset < 0) || (count <= 0)) return false; if ((source.length - srcOffset) < count) return false; if ((dest.length - destOffset) < count) return false; System.arraycopy(source, srcOffset, dest, destOffset, count); return true; } public static boolean blockCopy(ByteBuffer source, int srcOffset, byte[] dest, int destOffset, int count) { if ((source == null) || (dest == null)) return false; if ((srcOffset < 0) || (destOffset < 0) || (count <= 0)) return false; if ((source.limit() - srcOffset) < count) return false; if ((dest.length - destOffset) < count) return false; source.position(srcOffset); source.get(dest, destOffset, count); return true; } public static boolean blockCopy(byte[] source, int srcOffset, ByteBuffer dest, int destOffset, int count) { if ((source == null) || (dest == null)) return false; if ((srcOffset < 0) || (destOffset < 0) || (count <= 0)) return false; if ((source.length - srcOffset) < count) return false; if ((dest.limit() - destOffset) < count) return false; dest.position(destOffset); dest.put(source, srcOffset, count); return true; } public static boolean blockCopy(ByteBuffer source, int srcOffset, ByteBuffer dest, int destOffset, int count) { if ((source == null) || (dest == null)) return false; if ((srcOffset < 0) || (destOffset < 0) || (count <= 0)) return false; if ((source.limit() - srcOffset) < count) return false; if ((dest.limit() - destOffset) < count) return false; int sl = source.limit(); source.limit(srcOffset + count); dest.position(destOffset); dest.put(source); source.limit(sl); return true; } }