Here you can find the source of allocate(int length, byte fillwith)
public static ByteBuffer allocate(int length, byte fillwith)
//package com.java2s; /* Copyright 2004 - 2007 Kasper Nielsen <kasper@codehaus.org> Licensed under * the Apache 2.0 License, see http://coconut.codehaus.org/license. *//*from w w w .ja v a 2 s. c o m*/ import java.nio.ByteBuffer; public class Main { public static ByteBuffer allocate(int length, byte fillwith) { byte[] bytes = new byte[length]; for (int i = 0; i < length; i++) bytes[i] = fillwith; return ByteBuffer.wrap(bytes); } }