Category Archive for: Input/output: Exploring java.io

BufferedinputStream

BufferedinputStream Buffering I/O is  very common performance optimization. Java’s BufferedinputStream class allows you to “wrap” any InputStream into a buffered stream and achieve this performance improvement. BufferedinputStream has ?,O constructors: Bufferedlnputfitreamflnputetream inputStream) BufferedInputStream(1t1pulStream inputStream/ll, int bufSize) The first form creates a buffered stream using a default buffer size. In the second, the size of the buffer is passed…

Read More →

Filtered Byte Streams

Filtered Byte Streams Filtered streams are simply wrappers around underlying input or output streams that, transparently provide some extended level of functionality. These streams are typically accessed by methods that are expecting a generic stream, which is a superclass of the filtered streams. Typical extensions are buffering, character translation, and raw data translation. The filtered byte streams are Filtc!InputStream…

Read More →

ByteArrayinputStream

ByteArrayinputStream ByteArrayinputStream is an implementation of an input stream that USes a byte array as the source. This class has two constructors, each of which requires a byte array to provide the data source: ByteArraylnputStream(byte array[ ]) ByteArrayInputStream(byte array[ ], int start, int null mBytes) Here, array is the input source. The second constructor creates an InputStream…

Read More →

Fileinputstream

Fileinputstream The FileinputStream class creates an InputStream that you can use to read bytes from a file. Its two most common constructors are shown here Either can throw a FileNotfoundexception. Here,ji/cpatt Is the full path name of a file Is a File object that describes the file. The following example creates two Files input Streams that…

Read More →

InputStream

InputStream InputStream is an abstract class that defines Java’s mocu of streaming byte input. All of the methods in this class will throw an IOException on error conditions.Shows the methods in InputStream. Method                                              …

Read More →

The Stream Classes

The Stream Classes Java’s stream-based I/O is built upon four abstract classes: Inputstream, OutputStream, Reader, and Writer. These classes were briefly discussed in Chapter 12.They arc used to create several concrete stream subclasses. Although YOU’ll’ programs perform their I/O operations through concrete SUbclasses,the top-level classes define the basic functionality common to all stream classes. InputStream and OutputStream arc designed…

Read More →

The IistFiles ( ) Alternative

The listFiles ( ) Alternative java 2  adds  variation to the list( ) method, called listfile( ), which you might find useful. The signatures for listfile( ) are shown here: Filer[ ] listFiles( ) Filer[ ] listFiles(filenamefilter FFObj) File[ ] listFiles(FileFilter FObj) These methods return the file list .1S an array of File objects instead of…

Read More →

Directories

Directories A directory is a File that contains a list or other files and directories. When you create a. File object and it is a directory, the Directory( ) method will return true. In this case, you can roll stf ) on the object to extract the list of other files and directories inside; It has two…

Read More →

File

File Although most of classes defined by java.io operate on streams, the File class does not. It deals directly with files-and the file system. That is, the File Class does not specify how information is retrieved from or stored in files; it describes the properties of a file itself. A File object is used to obtain or manipulate…

Read More →

Input/output: Exploring java.io

Input/output: Exploring java.io This chapter expl~res [ava.lo, which provides support for 1(0 oper?tions. In  Chapter 12, we introduced Java’s I/O system. Here, we will exanune the java I/O system in greater detail. As all programmers learn early on, most programs cannot accomplish their goals e: without accessing external data. Data is retrieved from an input source, The…

Read More →

Back to Top