Input and output streams:
Java relies on the concept of a stream for providing its input/output facilities. A stream, sometimes referred to as a byte stream, is essentially a sequence of bytes, representing a flow of data from a source to a destination. Java streams provide facilities to handle these flows of data in a consistent way for a wide variety of sources and destinations, including the keyboard, screen and various sorts of data files, as well as between networked computers. They also allow manipulation of the data on the way: for example, by converting the data to different formats or by storing it temporarily (buffering).
All the streams provided in Java can be found in the java.io package. Any program that uses streams needs to include the statement:
import java.io.*;
A glance at the online documentation for the java.io library shows a bewildering variety of different stream classes.
Figure: Partial class hierarchy of Java stream classes for character input
Figure: Partial class hierarchy of Java stream classes for character output
Figure: Partial class hierarchy of Java stream classes for byte input
Figure: Partial class hierarchy of Java stream classes for byte output
We will explain the reason for the many different kinds and how to select the ones you need.
- There are streams for input, like InputStreamReader, and streams for output, like OutputStreamWriter.
- Some streams deal with data in terms of bytes, namely InputStream, OutputStream and their subclasses. Classes like Reader, Writer and their subclasses handle character data (recall that Java uses the two-byte Unicode representation of characters).
- We can also categorize streams into those that represent a source or a destination (such as a data file or a network connection), for example FileReader, as opposed to streams that allow modification or management of the stream data, such as LineNumberReader or BufferedWriter.
This wide variety can be confusing so in the following sections we shall look at some simple examples for typical input and output requirements. Note that the four classes that form the roots of the various hierarchies, namely Reader, Writer, InputStream and OutputStream, are all abstract classes. This means that you cannot create objects of these classes, only of their subclasses. Fortunately, they have no shortage of subclasses, so this does not pose a problem.
Java Assignment Help - Java Homework Help
Struggling with java programming language? Are you not finding solution for your Input and output streams homework and assignments? Live Input and output streams experts are working for students by solving their doubts & questions during their course studies and training program. We at Expertsmind.com offer Input and output streams homework help, java assignment help and Input and output streams projects help anytime from anywhere for 24x7 hours. Computer science programming assignments help making life easy for students.
Why Expertsmind for assignment help
- Higher degree holder and experienced experts network
- Punctuality and responsibility of work
- Quality solution with 100% plagiarism free answers
- Time on Delivery
- Privacy of information and details
- Excellence in solving java programming language queries in excels and word format.
- Best tutoring assistance 24x7 hours