java.io.FileInputStream Maven / Gradle / Ivy
/*
This is not an official specification document, and usage is restricted.
NOTICE
(c) 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
Neither this file nor any files generated from it describe a complete
specification, and they may only be used as described below. For
example, no permission is given for you to incorporate this file, in
whole or in part, in an implementation of a Java specification.
Sun Microsystems Inc. owns the copyright in this file and it is provided
to you for informative, as opposed to normative, use. The file and any
files generated from it may be used to generate other informative
documentation, such as a unified set of documents of API signatures for
a platform that includes technologies expressed as Java APIs. The file
may also be used to produce "compilation stubs," which allow
applications to be compiled and validated for such platforms.
Any work generated from this file, such as unified javadocs or compiled
stub files, must be accompanied by this notice in its entirety.
This work corresponds to the API signatures of JSR 219: Foundation
Profile 1.1. In the event of a discrepency between this work and the
JSR 219 specification, which is available at
http://www.jcp.org/en/jsr/detail?id=219, the latter takes precedence.
*/
package java.io;
/**
* A FileInputStream
obtains input bytes
* from a file in a file system. What files
* are available depends on the host environment.
*
*
FileInputStream
is meant for reading streams of raw bytes
* such as image data. For reading streams of characters, consider using
* FileReader
.
*
* @author Arthur van Hoff
* @version 1.45, 02/02/00
* @see java.io.File
* @see java.io.FileDescriptor
* @see java.io.FileOutputStream
* @since JDK1.0
*/
public class FileInputStream extends InputStream
{
/**
* 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.
*
* @param name the system-dependent file name.
* @exception FileNotFoundException if the file does not exist,
* is a directory rather than a regular file,
* or for some other reason cannot be opened for
* reading.
* @exception SecurityException if a security manager exists and its
* checkRead
method denies read access
* to the file.
* @see java.lang.SecurityManager#checkRead(java.lang.String)
*/
public FileInputStream(String name) throws FileNotFoundException { }
/**
* 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.
*
* @param file the file to be opened for reading.
* @exception FileNotFoundException if the file does not exist,
* is a directory rather than a regular file,
* or for some other reason cannot be opened for
* reading.
* @exception SecurityException if a security manager exists and its
* checkRead
method denies read access to the file.
* @see java.io.File#getPath()
* @see java.lang.SecurityManager#checkRead(java.lang.String)
*/
public FileInputStream(File file) throws FileNotFoundException { }
/**
* 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.
*
* @param fdObj the file descriptor to be opened for reading.
* @throws SecurityException if a security manager exists and its
* checkRead
method denies read access to the
* file descriptor.
* @see SecurityManager#checkRead(java.io.FileDescriptor)
*/
public FileInputStream(FileDescriptor fdObj) { }
/**
* Reads a byte of data from this input stream. This method blocks
* if no input is yet available.
*
* @return the next byte of data, or -1
if the end of the
* file is reached.
* @exception IOException if an I/O error occurs.
*/
public int read() throws IOException {
return 0;
}
/**
* Reads up to b.length
bytes of data from this input
* stream into an array of bytes. This method blocks until some input
* is available.
*
* @param b the buffer into which the data is read.
* @return the total number of bytes read into the buffer, or
* -1
if there is no more data because the end of
* the file has been reached.
* @exception IOException if an I/O error occurs.
*/
public int read(byte[] b) throws IOException {
return 0;
}
/**
* Reads up to len
bytes of data from this input stream
* into an array of bytes. This method blocks until some input is
* available.
*
* @param b the buffer into which the data is read.
* @param off the start offset of the data.
* @param len the maximum number of bytes read.
* @return the total number of bytes read into the buffer, or
* -1
if there is no more data because the end of
* the file has been reached.
* @exception IOException if an I/O error occurs.
*/
public int read(byte[] b, int off, int len) throws IOException {
return 0;
}
/**
* Skips over and discards n
bytes of data from the
* input stream. The skip
method may, for a variety of
* reasons, end up skipping over some smaller number of bytes,
* possibly 0
. The actual number of bytes skipped is returned.
*
* @param n the number of bytes to be skipped.
* @return the actual number of bytes skipped.
* @exception IOException if an I/O error occurs.
*/
public long skip(long n) throws IOException {
return -1;
}
/**
* Returns the number of bytes that can be read from this file input
* stream without blocking.
*
* @return the number of bytes that can be read from this file input
* stream without blocking.
* @exception IOException if an I/O error occurs.
*/
public int available() throws IOException {
return 0;
}
/**
* Closes this file input stream and releases any system resources
* associated with the stream.
*
*
If this stream has an associated channel then the channel is closed
* as well.
*
* @exception IOException if an I/O error occurs.
*
* @revised 1.4
* @spec JSR-51
*/
public void close() throws IOException { }
/**
* Returns the FileDescriptor
* object that represents the connection to
* the actual file in the file system being
* used by this FileInputStream
.
*
* @return the file descriptor object associated with this stream.
* @exception IOException if an I/O error occurs.
* @see java.io.FileDescriptor
*/
public final FileDescriptor getFD() throws IOException {
return null;
}
/**
* Ensures that the close
method of this file input stream is
* called when there are no more references to it.
*
* @exception IOException if an I/O error occurs.
* @see java.io.FileInputStream#close()
*/
protected void finalize() throws IOException { }
}