Here you can find the source of fill(ByteBuffer buffer, int position, int length, byte filler)
public static void fill(ByteBuffer buffer, int position, int length, byte filler)
//package com.java2s; /**// ww w .j a v a2 s .c om * Copyright (c) 2012, 2014 Sme.UP and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * * Contributors: * Mattia Rocchi - Initial API and implementation */ import java.nio.ByteBuffer; import java.util.Arrays; public class Main { public static void fill(ByteBuffer buffer, int position, int length, byte filler) { if (buffer.hasArray()) Arrays.fill(buffer.array(), position, length, filler); else { for (int i = position; i < length; i++) { buffer.put(filler); } } } }