# NewDirectByteBuffer

> Allocates and returns a direct java.nio.ByteBuffer referring to the block of memory starting at the memory address address and extending capacity bytes.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/7000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.AndroidJNIModule

## NewDirectByteBuffer(byte\*, long)

Allocates and returns a direct java.nio.ByteBuffer referring to the block of memory starting at the memory address address and extending capacity bytes.

```csharp
public static nint NewDirectByteBuffer(byte* buffer, long capacity)
```

### Parameters

**** (\[byte\*]\(https\://learn.microsoft.com/dotnet/api/system.byte)): The block of memory the buffer refers to.**** (\[long]\(https\://learn.microsoft.com/dotnet/api/system.int64)): The capacity, in bytes, of the memory region.

### Returns

| Type                                                           | Description                                                   |
| -------------------------------------------------------------- | ------------------------------------------------------------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) | A local reference to the newly allocated java.nio.ByteBuffer. |

### Remarks

Additional Resources: [Java Native Interface Specification (Oracle)](http://download.oracle.com/javase/1.5.0/docs/guide/jni/spec/jniTOC.html)

## NewDirectByteBuffer(NativeArray\<byte>)

Allocates and returns a direct java.nio.ByteBuffer referring to the same block of memory as the given NativeArray.

```csharp
public static nint NewDirectByteBuffer(NativeArray<byte> buffer)
```

### Parameters

**** (\[NativeArray\<byte>]\(/engine/7000.0/script-reference/unity/collections/nativearray1)): The block of memory the buffer refers to.

### Returns

| Type                                                           | Description                                                   |
| -------------------------------------------------------------- | ------------------------------------------------------------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) | A local reference to the newly allocated java.nio.ByteBuffer. |

### Remarks

Additional Resources: [Java Native Interface Specification (Oracle)](http://download.oracle.com/javase/1.5.0/docs/guide/jni/spec/jniTOC.html)

## NewDirectByteBuffer(NativeArray\<sbyte>)

Allocates and returns a direct java.nio.ByteBuffer referring to the same block of memory as the given NativeArray.

```csharp
public static nint NewDirectByteBuffer(NativeArray<sbyte> buffer)
```

### Parameters

**** (\[NativeArray\<sbyte>]\(/engine/7000.0/script-reference/unity/collections/nativearray1)): The block of memory the buffer refers to.

### Returns

| Type                                                           | Description                                                   |
| -------------------------------------------------------------- | ------------------------------------------------------------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) | A local reference to the newly allocated java.nio.ByteBuffer. |

### Remarks

Additional Resources: [Java Native Interface Specification (Oracle)](http://download.oracle.com/javase/1.5.0/docs/guide/jni/spec/jniTOC.html)
