FileChannel.Truncate(Int64) Method

Definition

Truncates this channel's file to the given size.

[Android.Runtime.Register("truncate", "(J)Ljava/nio/channels/FileChannel;", "GetTruncate_JHandler")]
public abstract Java.Nio.Channels.FileChannel? Truncate (long size);
[<Android.Runtime.Register("truncate", "(J)Ljava/nio/channels/FileChannel;", "GetTruncate_JHandler")>]
abstract member Truncate : int64 -> Java.Nio.Channels.FileChannel

Parameters

size
Int64

The new size, a non-negative byte count

Returns

This file channel

Attributes

Exceptions

if the requested size is negative.

if this channel is closed.

if the channel cannot be written to.

if another I/O error occurs.

Remarks

Truncates this channel's file to the given size.

If the given size is less than the file's current size then the file is truncated, discarding any bytes beyond the new end of the file. If the given size is greater than or equal to the file's current size then the file is not modified. In either case, if this channel's file position is greater than the given size then it is set to that size.

Java documentation for java.nio.channels.FileChannel.truncate(long).

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