Share via


FileInputStream Constructors

Definition

Overloads

FileInputStream(File)

Creates a FileInputStream by opening a connection to an actual file, the file named by the File object file in the file system.

FileInputStream(FileDescriptor)

Creates a FileInputStream by using the file descriptor fdObj, which represents an existing connection to an actual file in the file system.

FileInputStream(String)

Creates a FileInputStream by opening a connection to an actual file, the file named by the path name name in the file system.

FileInputStream(IntPtr, JniHandleOwnership)

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

FileInputStream(File)

Creates a FileInputStream by opening a connection to an actual file, the file named by the File object file in the file system.

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

Parameters

file
File

the file to be opened for reading.

Attributes

Exceptions

if file does not exist.

Remarks

Creates a FileInputStream by opening a connection to an actual file, the file named by the File object file in the file system. A new FileDescriptor object is created to represent this file connection.

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

If the named file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading then a FileNotFoundException is thrown.

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

FileInputStream(FileDescriptor)

Creates a FileInputStream by using the file descriptor fdObj, which represents an existing connection to an actual file in the file system.

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

Parameters

fdObj
FileDescriptor

the file descriptor to be opened for reading.

Attributes

Exceptions

if fd is null.

Remarks

Creates a FileInputStream by using the file descriptor fdObj, which represents an existing connection to an actual file in the file system.

If there is a security manager, its checkRead method is called with the file descriptor fdObj as its argument to see if it's ok to read the file descriptor. If read access is denied to the file descriptor a SecurityException is thrown.

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.FileInputStream.FileInputStream(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

FileInputStream(String)

Creates a FileInputStream by opening a connection to an actual file, the file named by the path name name in the file system.

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

Parameters

name
String

the system-dependent file name.

Attributes

Exceptions

Remarks

Creates a FileInputStream by opening a connection to an actual file, the file named by the path name name in the file system. A new FileDescriptor object is created to represent this file connection.

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

If the named file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading then a FileNotFoundException is thrown.

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

FileInputStream(IntPtr, JniHandleOwnership)

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

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

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