Академический Документы
Профессиональный Документы
Культура Документы
File class
Used only to know the details about the file. Cannot be used to read or write bytes into file. Helps to study the file before handling it.
File(String dirpath) File(String dirpath, String filename) File(File object, String filename)
Methods
String getName() String getPath() String getAbsolutePath() String getParent() boolean exists() boolean canWrite() boolean canRead() boolean isDirectory() boolean isFile() boolean isHidden()
long lastModified() long length() boolean renameTo(File newname) boolean delete() boolean setReadOnly() void deleteOnExit() String[] list()
FileInputStream
Read bytes from a disk file.
FileInputStream(String filename) FileInputStream(File object)
FileOutputStream
FileOutputStream(String filename) FileOutputStream(File fobject) FileOutputStream(String filename, boolean append) The above constructors throw an IOException or SecurityException.
Memory Handling
ByteArrayInputStream ByteArrayOutputStream
ByteArrayInputStream
Used to read bytes from a memory. Objects of this class are used to create input stream with memory buffers as data source. Constructors
ByteArrayInputStream(byte b[]) ByteArrayInputStream(byte b[], int off, int len)
ByteArrayOutputStream
Write bytes into memory. Objects of this class are used to create output stream with memory buffers as data sink. Constructors :
ByteArrayOutputStream() ByteArrayOutputStream(int len)
will throw IllegalArgumentException is len is negative.
Char, string
Input Stream
Data Source
char, string
Filtered Outputstream
byte
OutputStream
Data Sink
BufferedInputStream
This class is used to increase the efficiency of reading bytes from an input stream. Fetching a byte and sending it to the destination one after another is a time consuming process. Instead bytes can be read and stored in a buffer memory before sending it to the destination. Once, the buffer is full, the bytes can be sent to the destination.
BufferedOutputStream
Subclass of FilterOutputStream. This class is used to send buffered bytes to an underlying output stream in an efficient way. Constructors :
BufferedOutputStream(OutputStream ous) BufferedOutputStream(OutputStream ous, int size)