Added BufferChecks.checkNullTerminated

This commit is contained in:
Elias Naur 2005-02-09 13:44:52 +00:00
parent 9c337a25eb
commit dcb726d7da
1 changed files with 9 additions and 0 deletions

View File

@ -58,6 +58,15 @@ public class BufferChecks {
*/
private static final int DEFAULT_BUFFER_SIZE = 4;
/**
* Helper methods to ensure a ByteBuffer is null-terminated
*/
public static void checkNullTerminated(ByteBuffer buf) {
if (buf.get(buf.limit() - 1) != 0) {
throw new IllegalArgumentException("Missing null termination");
}
}
/**
* Helper methods to ensure a buffer is direct or null.
*/