# 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/6000.5/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)): **** (\[long]\(https\://learn.microsoft.com/dotnet/api/system.int64)):&#x20;

### Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) |             |

### 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/6000.5/script-reference/unity/collections/nativearray1)):&#x20;

### Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) |             |

### 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/6000.5/script-reference/unity/collections/nativearray1)):&#x20;

### Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) |             |

### Remarks

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