Skip to main content Accessibility help
Internet Explorer 11 is being discontinued by Microsoft in August 2021. If you have difficulties viewing the site on Internet Explorer 11 we recommend using a different browser such as Microsoft Edge, Google Chrome, Apple Safari or Mozilla Firefox.

Chapter 8: Java IO and File

Chapter 8: Java IO and File

pp. 519-653

Authors

, Indian Institute of Technology, Kharagpur, , Indian Institute of Technology, Kharagpur
  • Add bookmark
  • Cite
  • Share

Extract

Input and output are two most important operations in any software system design. This is particularly significant with modern Internet and communication technology where there are many modes of input–output from many sources. This versatility of input–output brings a challenge to software systems developer. Fortunately, Java developer has java.io, which provides a brilliant method of managing data in an easy, programmer-friendly, reliable, and robust manner. Today java.io API is admired as one of the finest packages which facilitates data manipulation in the best possible way. The addendum java. nio offers several features to implement intensive and high-speed IO operations. This chapter gives you an understanding of handling input-output in programs in Java.

Introduction

Real-world programming requirements In the previous chapters, you have studied a little about input and output related methods in Java. Chapter 2 mentioned input to programs and output from programs considering the programs are simple and text-based (reading from keyboard), and writing output on the console (display). However, in many real world applications, input–output are more versatile: inputs are from many different sources (such as files, other programs, network channels, etc.); similarly, outputs from a program may go into several destinations like files, external programs, network lines in web, etc. (Figure 8.1).

Java’s key to success While a majority of programming languages are keyboard–console input and output (IO), Java is much ahead of them, supporting efficient, strong, and flexible real-world programming with networking, files, and many more options. Java includes the java.io package which contains nearly every class you might ever need to perform IO. As a unique concept, Java introduced stream for flow of different forms of data to-and-fro the sources and destinations. There are numerous classes representing different streams for input sources and output destinations. The streams in the java.io package support many kinds of data such as primitives, object, localized characters, etc.

The java.io package is vast. It defines over seventy classes and interfaces, many of which have a large number of methods. Covering all of them in detail is beyond the scope of this book and often it is not necessary for a programmer to know about them.

About the book

Access options

Review the options below to login to check your access.

Purchase options

eTextbook
US$99.99
Paperback
US$99.99

Have an access code?

To redeem an access code, please log in with your personal login.

If you believe you should have access to this content, please contact your institutional librarian or consult our FAQ page for further information about accessing our content.

Also available to purchase from these educational ebook suppliers