NetworkUstad
  • Technology
  • CCNA
  • Networking
  • Cyber Security
  • BLOG
  • Contact
  • Technology
  • CCNA
  • Networking
  • Cyber Security
  • BLOG
  • Contact

Input and Output Streams

Michael Caine / Education /

August 29, 2021
Input and Output Streams

Many Java programs need to read or write data. In this tutorial, you have seen several example programs that read and write data. For example, the sample program in the Java Nuts and Bolts section (in the Writing Java Programs journal) reads user input and writes the data to the display, while the All About Sockets lesson (in the Journal Network Connections ”), which you will read later, contains several examples that read and write data over a network using sockets. All of these sample programs read and write to streams.

Definition: A stream is a continuous sequence of characters.

Your program can receive input from a data source by reading sequence characters from a stream attached to the source. Your program can generate output by typing the order of the characters in the output stream attached to the destination. The Java IDE includes the java.io package, which includes a set of input and output streams that your programs can use to read and write data.

Input stream and output stream classes in java.io are abstract superclasses that explain the behavior of input and output streams, respectively, in Java. Java.io also includes several subclasses of input streams and output streams that implement specific types of input and output streams. This tutorial explains what each class in java.io does, how you decide which ones to use, how to use them, and how you can sub- take a class to write your own stream classes.

Although this tutorial does not provide examples for all types of input and output streams available in the java.io package, it does provide several practical examples of using the most popular classes in java.io.

Your first encounter with Java I / O

You may have encountered I / O streams in Java before, thanks to the standard output, standard error, and the use of standard input streams managed by the system.

Overview of input and output streams.

Your Java programs use input streams to read data from some input sources and output streams to write data to some output sources. Sources of input and output can be anything that can contain data: file, string, or memory.

Using input and output streams

This section shows pairs of input and output streams that derive directly from InputStream and OutputStream, and provides examples of their use.

Working with Filtered Streams

The java.io package contains several I / O streams that belong to a set of streams known as filtered streams that filter data as it is read from or written to the stream. BufferedInputStream and BufferedOutputStream are two such filtered streams that buffer data as it reads and writes, making the stream more efficient.

Working with random access files

In java input output overview, the InputStream and OutputStream subclasses produce serial files – files that need to be processed from start to finish. A random access file gives your programs the ability to access data in a file in an inconsistent (or random) order. RandomAccessFile in java.io implements a file that you can access in an inconsistent manner.

Security considerations: Input and output on the local file system are subject to approval by the current security manager. The sample programs contained in these lessons are stand-alone applications that do not have a Security Manager by default. If you try to use this code in applets, it may not work depending on the browser or viewer in which they are running. See “Understanding the Features and Limitations of Applets” (in the Writing Applet Journal) for information on the security restrictions imposed on applets.

Michael Caine ANO Digital

→ Michael Caine ANO Digital

« 6 Reasons Why You Need to Learn Business Management Skills» 5 Reasons Why Vegan Cream Cheese Is Great for Health
NetworkUstad

Master the Digital Frontier with our expert IT training and resources.

Quick Links

  • About Us
  • Our Services
  • Blog
  • Tutorials
  • Contact Us
  • FAQs

Contact Us

admin@networkustad.com

Recent Posts

HOUSE PAINTERS NEAR PITTSBURGH ARE TRAINED IN PRESERVING YOUR HISTORICAL HOME

June 16, 2025

What Features Do Modern Garage Doors Have?

June 16, 2025

How to Get Your Property Improvement Business Off the Ground

June 15, 2025
© 2025 NetworkUstad. All Rights Reserved.
  • Privacy Policy
  • Terms of Service
  • Sitemap
Designed with by NetworkUstad
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT
Powered by CookieYes Logo