Share via


RandomAccessFile.SetLength(Int64) Method

Definition

Sets the length of this file.

[Android.Runtime.Register("setLength", "(J)V", "GetSetLength_JHandler")]
public virtual void SetLength (long newLength);
[<Android.Runtime.Register("setLength", "(J)V", "GetSetLength_JHandler")>]
abstract member SetLength : int64 -> unit
override this.SetLength : int64 -> unit

Parameters

newLength
Int64

The desired length of the file

Attributes

Exceptions

if newLength .

if this file is closed or another I/O error occurs.

Remarks

Sets the length of this file.

If the present length of the file as returned by the length method is greater than the newLength argument then the file will be truncated. In this case, if the file offset as returned by the getFilePointer method is greater than newLength then after this method returns the offset will be equal to newLength.

If the present length of the file as returned by the length method is smaller than the newLength argument then the file will be extended. In this case, the contents of the extended portion of the file are not defined.

Added in 1.2.

Java documentation for java.io.RandomAccessFile.setLength(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