Android ByteBuffer Get allocateMore(ByteBuffer output)

Here you can find the source of allocateMore(ByteBuffer output)

Description

allocate More

License

Apache License

Declaration

private static ByteBuffer allocateMore(ByteBuffer output) 

Method Source Code

//package com.java2s;
/*//from   w ww.  j a  va2 s . c  o m
 *    Copyright 2013 TOYAMA Sumio <jun.nama@gmail.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.
 * 
 * ----
 * getBytes(), encode() and allocateMore() are modifications based on
 * work copyrighted and licensed as follows:
 * 
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.nio.ByteBuffer;

public class Main {
    private static ByteBuffer allocateMore(ByteBuffer output) {
        if (output.capacity() == 0) {
            return ByteBuffer.allocate(1);
        }
        ByteBuffer result = ByteBuffer.allocate(output.capacity() * 2);
        output.flip();
        result.put(output);
        return result;
    }
}

Related

  1. getUnsignedByte(final ByteBuffer pByteBuffer)
  2. getUnsignedByte(final ByteBuffer pByteBuffer, final int pPosition)
  3. getUnsignedInt(final ByteBuffer pByteBuffer)
  4. getUnsignedInt(final ByteBuffer pByteBuffer, final int pPosition)
  5. extractNullTerminatedString(ByteBuffer bb)
  6. removeFirstBytes(ByteBuffer buffer, int num)
  7. shorts(ByteBuffer buffer)
  8. getObject(ByteBuffer byteBuffer)
  9. skip(ByteBuffer buffer, int length)