Share via


FileOutputStream Constructors

Definition

Overloads

FileOutputStream(File)

Creates a file output stream to write to the file represented by the specified File object.

FileOutputStream(FileDescriptor)

Creates a file output stream to write to the specified file descriptor, which represents an existing connection to an actual file in the file system.

FileOutputStream(String)

Creates a file output stream to write to the file with the specified name.

FileOutputStream(File, Boolean)

Creates a file output stream to write to the file represented by the specified File object.

FileOutputStream(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

FileOutputStream(String, Boolean)

Creates a file output stream to write to the file with the specified name.

FileOutputStream(File)

Creates a file output stream to write to the file represented by the specified File object.

[Android.Runtime.Register(".ctor", "(Ljava/io/File;)V", "")]
public FileOutputStream (Java.IO.File? file);
[<Android.Runtime.Register(".ctor", "(Ljava/io/File;)V", "")>]
new Java.IO.FileOutputStream : Java.IO.File -> Java.IO.FileOutputStream

Parameters

file
File

the file to be opened for writing.

Attributes

Exceptions

if file cannot be opened for writing.

Remarks

Creates a file output stream to write to the file represented by the specified File object. A new FileDescriptor object is created to represent this file connection.

First, if there is a security manager, its checkWrite method is called with the path represented by the file argument as its argument.

If the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason then a FileNotFoundException is thrown.

Java documentation for java.io.FileOutputStream.FileOutputStream(java.io.File).

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

FileOutputStream(FileDescriptor)

Creates a file output stream to write to the specified file descriptor, which represents an existing connection to an actual file in the file system.

[Android.Runtime.Register(".ctor", "(Ljava/io/FileDescriptor;)V", "")]
public FileOutputStream (Java.IO.FileDescriptor? fdObj);
[<Android.Runtime.Register(".ctor", "(Ljava/io/FileDescriptor;)V", "")>]
new Java.IO.FileOutputStream : Java.IO.FileDescriptor -> Java.IO.FileOutputStream

Parameters

fdObj
FileDescriptor

the file descriptor to be opened for writing

Attributes

Exceptions

if fd is null.

Remarks

Creates a file output stream to write to the specified file descriptor, which represents an existing connection to an actual file in the file system.

First, if there is a security manager, its checkWrite method is called with the file descriptor fdObj argument as its argument.

If fdObj is null then a NullPointerException is thrown.

This constructor does not throw an exception if fdObj is java.io.FileDescriptor#valid() invalid. However, if the methods are invoked on the resulting stream to attempt I/O on the stream, an IOException is thrown.

Android-specific warning: #close() method doesn't close the fdObj provided, because this object doesn't own the file descriptor, but the caller does. The caller can call android.system.Os#close(FileDescriptor) to close the fd.

Java documentation for java.io.FileOutputStream.FileOutputStream(java.io.FileDescriptor).

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

FileOutputStream(String)

Creates a file output stream to write to the file with the specified name.

[Android.Runtime.Register(".ctor", "(Ljava/lang/String;)V", "")]
public FileOutputStream (string? name);
[<Android.Runtime.Register(".ctor", "(Ljava/lang/String;)V", "")>]
new Java.IO.FileOutputStream : string -> Java.IO.FileOutputStream

Parameters

name
String

the system-dependent filename

Attributes

Exceptions

if file cannot be opened for writing.

Remarks

Creates a file output stream to write to the file with the specified name. A new FileDescriptor object is created to represent this file connection.

First, if there is a security manager, its checkWrite method is called with name as its argument.

If the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason then a FileNotFoundException is thrown.

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

FileOutputStream(File, Boolean)

Creates a file output stream to write to the file represented by the specified File object.

[Android.Runtime.Register(".ctor", "(Ljava/io/File;Z)V", "")]
public FileOutputStream (Java.IO.File? file, bool append);
[<Android.Runtime.Register(".ctor", "(Ljava/io/File;Z)V", "")>]
new Java.IO.FileOutputStream : Java.IO.File * bool -> Java.IO.FileOutputStream

Parameters

file
File

the file to be opened for writing.

append
Boolean

if true, then bytes will be written to the end of the file rather than the beginning

Attributes

Exceptions

if the file cannot be opened for writing.

Remarks

Creates a file output stream to write to the file represented by the specified File object. If the second argument is true, then bytes will be written to the end of the file rather than the beginning. A new FileDescriptor object is created to represent this file connection.

First, if there is a security manager, its checkWrite method is called with the path represented by the file argument as its argument.

If the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason then a FileNotFoundException is thrown.

Added in 1.4.

Java documentation for java.io.FileOutputStream.FileOutputStream(java.io.File, boolean).

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

FileOutputStream(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

protected FileOutputStream (IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer);
new Java.IO.FileOutputStream : nativeint * Android.Runtime.JniHandleOwnership -> Java.IO.FileOutputStream

Parameters

javaReference
IntPtr

nativeint

A IntPtrcontaining a Java Native Interface (JNI) object reference.

transfer
JniHandleOwnership

A JniHandleOwnershipindicating how to handle javaReference

Remarks

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

FileOutputStream(String, Boolean)

Creates a file output stream to write to the file with the specified name.

[Android.Runtime.Register(".ctor", "(Ljava/lang/String;Z)V", "")]
public FileOutputStream (string? name, bool append);
[<Android.Runtime.Register(".ctor", "(Ljava/lang/String;Z)V", "")>]
new Java.IO.FileOutputStream : string * bool -> Java.IO.FileOutputStream

Parameters

name
String

the system-dependent file name

append
Boolean

if true, then bytes will be written to the end of the file rather than the beginning

Attributes

Exceptions

if the file cannot be opened for writing.

Remarks

Creates a file output stream to write to the file with the specified name. If the second argument is true, then bytes will be written to the end of the file rather than the beginning. A new FileDescriptor object is created to represent this file connection.

First, if there is a security manager, its checkWrite method is called with name as its argument.

If the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason then a FileNotFoundException is thrown.

Added in JDK1.1.

Java documentation for java.io.FileOutputStream.FileOutputStream(java.lang.String, boolean).

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