by Dinesh Thakur Category: Stream

When a program is executed, the input is read from the various sources and the output is sent to different destinations. Generally, keyboard and monitor screen are used as standard input and output device, respectively.



 
by Dinesh Thakur Category: Stream

One of the limitations of byte stream classes is that it can handle only 8-bit bytes and cannot work directly with Unicode characters. To overcome this limitation, character stream classes have been introduced in java.io package to match the byte stream classes. The character stream classes support 16-bit Unicode characters, performing operations on characters, character arrays, or strings, reading or writing buffer at a time. Character stream classes are divided into two stream classes namely, Reader class and Writer class.



 
by Dinesh Thakur Category: Stream

Byte stream classes are used to perform reading and writing of 8-bit bytes. Streams being unidirectional in nature can transfer bytes in one direction only, that is, either reading data from the source into a program or writing data from a program to the destination. Therefore, Java further divides byte stream classes into two classes, namely, InputStream class and OutputStrearn class. The subclasses of InputStrearn class contain methods to support input and the subclasses of OutputStrearn class contain output related methods.

 
by Dinesh Thakur Category: Stream

The java.io package provides a set of abstract classes that define and partially implement Filter streams. A Filter stream filters data as it is being read from or written to the stream. The two filter streams for reading and writing data are Filter input Stream and Filter Output Stream ,respectively.



 
by Dinesh Thakur Category: Stream

The File class explains only the file system. Java provides two special types of stream called the File input Stream and File Output Stream to read data from and write data into the file. These classes operate on the files in the native file system. File input Stream and File Output Stream are subclasses of Input Stream and Output Stream, respectively. Usually, we use File input Stream(for byte streams) or File Reader (for character streams) for reading from a file and File Output Stream(for byte streams) or File Writer (for character streams) for writing into a file.

 
by Dinesh Thakur Category: Stream

A file can be created using File class.

                          File;

                          f = new File (string filename);

 
by Dinesh Thakur Category: Stream

Streams are represented in Java as classes. The java.io package defines a collection of stream classes that support input and output (reading and writing). To use these classes, a program needs to import the java.io package, as shown below



 
by Dinesh Thakur Category: Stream

A flow of data is often referred to as a data stream. A stream is an ordered sequence of bytes that has a SOURCE (input stream) or a DESTINATION (output stream). In simple terms, a stream can be defined as follows.

 
by Dinesh Thakur Category: Stream
 
 
by Dinesh Thakur Category: Stream
 
by Dinesh Thakur Category: Stream

The RandomAccessFile class provides a multitude of methods for reading and writing to and from files.

Although we can certainly use FileInputStream and FileOutputStream for file I/O,

RandomAccessFile provides many more features and options.

 
by Dinesh Thakur Category: Stream
 
by Dinesh Thakur Category: Stream

A Java application can accept any number of arguments from the command line. Command-line arguments allow the user to affect the operation of an application.

 
by Dinesh Thakur Category: Stream

We use FilelnputStream class for reading from the file as it creates an input byte stream for reading from the file. To read the contents from the file ecomputernotes.bat, we first make an object by name say fp of FileOutputStream class and specify the file name ecomputernotes.bat as an argument to the constructor:

 

Page 1 of 3



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles