Java ByteBuffer from getByteBuffer(byte[] data, int fromByte, int length)

Here you can find the source of getByteBuffer(byte[] data, int fromByte, int length)

Description

get Byte Buffer

License

Apache License

Declaration

public static ByteBuffer getByteBuffer(byte[] data, int fromByte, int length) 

Method Source Code


//package com.java2s;
/*//from www  .  j  a va  2s  . c  o  m
Copyright PNF Software, Inc.
    
https://www.pnfsoftware.com
    
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    
http://www.apache.org/licenses/LICENSE-2.0
    
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import java.io.ByteArrayOutputStream;
import java.nio.ByteBuffer;

public class Main {
    public static ByteBuffer getByteBuffer(byte[] data, int fromByte, int length) {
        return ByteBuffer.wrap(getByteArray(data, fromByte, length).toByteArray());
    }

    public static ByteArrayOutputStream getByteArray(byte[] data, int fromByte, int length) {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        bos.write(data, fromByte, length);
        return bos;
    }
}

Related

  1. getByteBuffer(byte[] array)
  2. getByteBuffer(ByteBuffer source, int count)
  3. getByteBuffer(final String string, final Charset charset)
  4. getByteBuffer(int size)
  5. getByteBuffer(Object obj)