Share via


CharBuffer.Put Method

Definition

Overloads

Put(String, Int32, Int32)

Relative bulk put method  (optional operation).

Put(Char[], Int32, Int32)

Relative bulk put method  (optional operation).

Put(Int32, Char)

Absolute put method  (optional operation).

Put(Char[])

Relative bulk put method  (optional operation).

Put(Char)

Relative put method  (optional operation).

Put(String)

Relative bulk put method  (optional operation).

Put(CharBuffer)

Relative bulk put method  (optional operation).

Put(String, Int32, Int32)

Relative bulk put method  (optional operation).

[Android.Runtime.Register("put", "(Ljava/lang/String;II)Ljava/nio/CharBuffer;", "GetPut_Ljava_lang_String_IIHandler")]
public virtual Java.Nio.CharBuffer? Put (string? src, int start, int end);
[<Android.Runtime.Register("put", "(Ljava/lang/String;II)Ljava/nio/CharBuffer;", "GetPut_Ljava_lang_String_IIHandler")>]
abstract member Put : string * int * int -> Java.Nio.CharBuffer
override this.Put : string * int * int -> Java.Nio.CharBuffer

Parameters

src
String

The string from which chars are to be read

start
Int32

The offset within the string of the first char to be read; must be non-negative and no larger than string.length()

end
Int32

The offset within the string of the last char to be read, plus one; must be non-negative and no larger than string.length()

Returns

This buffer

Attributes

Exceptions

if remaining() is less than end - start.

if either start or end is invalid.

if no changes may be made to the contents of this buffer.

Remarks

Relative bulk put method&nbsp;&nbsp;(optional operation).

This method transfers chars from the given string into this buffer. If there are more chars to be copied from the string than remain in this buffer, that is, if end&nbsp;-&nbsp;start&nbsp;&gt;&nbsp;remaining(), then no chars are transferred and a BufferOverflowException is thrown.

Otherwise, this method copies n&nbsp;=&nbsp;end&nbsp;-&nbsp;start chars from the given string into this buffer, starting at the given start index and at the current position of this buffer. The position of this buffer is then incremented by n.

In other words, an invocation of this method of the form dst.put(src,&nbsp;start,&nbsp;end) has exactly the same effect as the loop

{@code
                for (int i = start; i < end; i++)
                    dst.put(src.charAt(i));
            }

except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient.

Java documentation for java.nio.CharBuffer.put(java.lang.String, int, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Put(Char[], Int32, Int32)

Relative bulk put method&nbsp;&nbsp;(optional operation).

[Android.Runtime.Register("put", "([CII)Ljava/nio/CharBuffer;", "GetPut_arrayCIIHandler")]
public virtual Java.Nio.CharBuffer? Put (char[]? src, int offset, int length);
[<Android.Runtime.Register("put", "([CII)Ljava/nio/CharBuffer;", "GetPut_arrayCIIHandler")>]
abstract member Put : char[] * int * int -> Java.Nio.CharBuffer
override this.Put : char[] * int * int -> Java.Nio.CharBuffer

Parameters

src
Char[]

The array from which chars are to be read

offset
Int32

The offset within the array of the first char to be read; must be non-negative and no larger than array.length

length
Int32

The number of chars to be read from the given array; must be non-negative and no larger than array.length - offset

Returns

This buffer

Attributes

Exceptions

if remaining() is less than charCount.

if either srcOffset or charCount is invalid.

if no changes may be made to the contents of this buffer.

Remarks

Relative bulk put method&nbsp;&nbsp;(optional operation).

This method transfers chars into this buffer from the given source array. If there are more chars to be copied from the array than remain in this buffer, that is, if length&nbsp;&gt;&nbsp;remaining(), then no chars are transferred and a BufferOverflowException is thrown.

Otherwise, this method copies length chars from the given array into this buffer, starting at the given offset in the array and at the current position of this buffer. The position of this buffer is then incremented by length.

In other words, an invocation of this method of the form dst.put(src,&nbsp;off,&nbsp;len) has exactly the same effect as the loop

{@code
                for (int i = off; i < off + len; i++)
                    dst.put(a[i]);
            }

except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient.

Java documentation for java.nio.CharBuffer.put(char[], int, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Put(Int32, Char)

Absolute put method&nbsp;&nbsp;(optional operation).

[Android.Runtime.Register("put", "(IC)Ljava/nio/CharBuffer;", "GetPut_ICHandler")]
public abstract Java.Nio.CharBuffer? Put (int index, char c);
[<Android.Runtime.Register("put", "(IC)Ljava/nio/CharBuffer;", "GetPut_ICHandler")>]
abstract member Put : int * char -> Java.Nio.CharBuffer

Parameters

index
Int32

The index at which the char will be written

c
Char

The char value to be written

Returns

This buffer

Attributes

Exceptions

if index is invalid.

if no changes may be made to the contents of this buffer.

Remarks

Absolute put method&nbsp;&nbsp;(optional operation).

Writes the given char into this buffer at the given index.

Java documentation for java.nio.CharBuffer.put(int, char).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Put(Char[])

Relative bulk put method&nbsp;&nbsp;(optional operation).

[Android.Runtime.Register("put", "([C)Ljava/nio/CharBuffer;", "")]
public Java.Nio.CharBuffer? Put (char[]? src);
[<Android.Runtime.Register("put", "([C)Ljava/nio/CharBuffer;", "")>]
member this.Put : char[] -> Java.Nio.CharBuffer

Parameters

src
Char[]

The source array

Returns

This buffer

Attributes

Exceptions

if remaining() is less than src.length.

if no changes may be made to the contents of this buffer.

Remarks

Relative bulk put method&nbsp;&nbsp;(optional operation).

This method transfers the entire content of the given source char array into this buffer. An invocation of this method of the form dst.put(a) behaves in exactly the same way as the invocation

dst.put(a, 0, a.length)

Java documentation for java.nio.CharBuffer.put(char[]).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Put(Char)

Relative put method&nbsp;&nbsp;(optional operation).

[Android.Runtime.Register("put", "(C)Ljava/nio/CharBuffer;", "GetPut_CHandler")]
public abstract Java.Nio.CharBuffer? Put (char c);
[<Android.Runtime.Register("put", "(C)Ljava/nio/CharBuffer;", "GetPut_CHandler")>]
abstract member Put : char -> Java.Nio.CharBuffer

Parameters

c
Char

The char to be written

Returns

This buffer

Attributes

Exceptions

if position is equal or greater than limit.

if no changes may be made to the contents of this buffer.

Remarks

Relative put method&nbsp;&nbsp;(optional operation).

Writes the given char into this buffer at the current position, and then increments the position.

Java documentation for java.nio.CharBuffer.put(char).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Put(String)

Relative bulk put method&nbsp;&nbsp;(optional operation).

[Android.Runtime.Register("put", "(Ljava/lang/String;)Ljava/nio/CharBuffer;", "")]
public Java.Nio.CharBuffer? Put (string? src);
[<Android.Runtime.Register("put", "(Ljava/lang/String;)Ljava/nio/CharBuffer;", "")>]
member this.Put : string -> Java.Nio.CharBuffer

Parameters

src
String

The source string

Returns

This buffer

Attributes

Exceptions

if remaining() is less than the length of string.

if no changes may be made to the contents of this buffer.

Remarks

Relative bulk put method&nbsp;&nbsp;(optional operation).

This method transfers the entire content of the given source string into this buffer. An invocation of this method of the form dst.put(s) behaves in exactly the same way as the invocation

dst.put(s, 0, s.length())

Java documentation for java.nio.CharBuffer.put(java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Put(CharBuffer)

Relative bulk put method&nbsp;&nbsp;(optional operation).

[Android.Runtime.Register("put", "(Ljava/nio/CharBuffer;)Ljava/nio/CharBuffer;", "GetPut_Ljava_nio_CharBuffer_Handler")]
public virtual Java.Nio.CharBuffer? Put (Java.Nio.CharBuffer? src);
[<Android.Runtime.Register("put", "(Ljava/nio/CharBuffer;)Ljava/nio/CharBuffer;", "GetPut_Ljava_nio_CharBuffer_Handler")>]
abstract member Put : Java.Nio.CharBuffer -> Java.Nio.CharBuffer
override this.Put : Java.Nio.CharBuffer -> Java.Nio.CharBuffer

Parameters

src
CharBuffer

The source buffer from which chars are to be read; must not be this buffer

Returns

This buffer

Attributes

Exceptions

if src.remaining() is greater than this buffer's remaining().

if src is this buffer.

if no changes may be made to the contents of this buffer.

Remarks

Relative bulk put method&nbsp;&nbsp;(optional operation).

This method transfers the chars remaining in the given source buffer into this buffer. If there are more chars remaining in the source buffer than in this buffer, that is, if src.remaining()&nbsp;&gt;&nbsp;remaining(), then no chars are transferred and a BufferOverflowException is thrown.

Otherwise, this method copies n&nbsp;=&nbsp;src.remaining() chars from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.

In other words, an invocation of this method of the form dst.put(src) has exactly the same effect as the loop

while (src.hasRemaining())
                    dst.put(src.get()); 

except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient.

Java documentation for java.nio.CharBuffer.put(java.nio.CharBuffer).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to