Java examples for java.nio:ByteBuffer
Checks the first 16 bytes of the given ByteBuffer for a 0 byte.
//package com.java2s; import java.nio.*; public class Main { /**/*w ww . ja va 2s.com*/ * Checks the first 16 bytes of the given ByteBuffer for a 0 byte. * FIXME: this is a poor heuristic for anyone using UTF-16. */ public static boolean isBinaryByteBuffer(ByteBuffer byteBuffer, final int byteCount) { final int end = Math.min(byteCount, 16); for (int i = 0; i < end; ++i) { if (byteBuffer.get(i) == 0) { return true; } } return false; } }