Java ByteBuffer Write writeByteArray(ByteBuffer byteBuffer, byte[] bytes)

Here you can find the source of writeByteArray(ByteBuffer byteBuffer, byte[] bytes)

Description

write Byte Array

License

Open Source License

Declaration

public static void writeByteArray(ByteBuffer byteBuffer, byte[] bytes) 

Method Source Code


//package com.java2s;
/*/*from  w  w w .  j a  va 2  s. c o  m*/
 * (C) 2007-2010 Alibaba Group Holding Limited.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 */

import java.nio.ByteBuffer;

public class Main {
    public static void writeByteArray(ByteBuffer byteBuffer, byte[] bytes) {
        byteBuffer.put(bytes);
    }

    public static boolean writeByteArray(ByteBuffer byteBuffer, byte[] bytes, int offset, int length) {
        if (bytes.length < offset + length)
            return false;
        byteBuffer.put(bytes, offset, length);
        return true;
    }
}

Related

  1. writeBuffer(FileChannel fc, ByteBuffer buf, int startPos)
  2. writeBuffer(WritableByteChannel chan, ByteBuffer buf)
  3. writeByte(ByteBuffer dest, int off, int i)
  4. writeByteArray(byte[] array, ByteBuffer out)
  5. writeByteArray(byte[] data, ByteBuffer buffer)
  6. writeByteArray(ByteBuffer logBuf, byte[] b)
  7. writeByteBuffer(ByteBuffer bbuf, String filename)
  8. writeByteBuffer(RandomAccessFile file, ByteBuffer buffer)
  9. writeByteBuffer(WritableByteChannel channel, ByteBuffer buf, int bytesToWrite)