0% found this document useful (0 votes)
8 views

IOBasics

This document discusses I/O basics in Java. It covers that the io package supports file I/O and that most Java applications rely on graphical interfaces rather than text-based console programs. It also describes that Java performs I/O through streams, which are abstractions that produce or consume information and are linked to physical devices. Finally, it outlines the different types of streams in Java including byte streams for binary data and character streams for characters, and predefined streams like System.in and System.out.

Uploaded by

ngchowdhury
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

IOBasics

This document discusses I/O basics in Java. It covers that the io package supports file I/O and that most Java applications rely on graphical interfaces rather than text-based console programs. It also describes that Java performs I/O through streams, which are abstractions that produce or consume information and are linked to physical devices. Finally, it outlines the different types of streams in Java including byte streams for binary data and character streams for characters, and predefined streams like System.in and System.out.

Uploaded by

ngchowdhury
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 11

I/O Basics

I/O Basics
The io package of Java supports Javas basic I/O system, including file I/O (java.io ) We have not seen much I/O till now, because most real applications of Java are not text-based, console programs Rather, they are graphically oriented applets that rely upon Javas Abstract Window Toolkit (AWT) for interaction with the user

Streams
Java programs perform I/O through streams A stream is an abstraction that either produces or consumes information

A stream is linked to a physical device by the Java I/O system. All streams behave the same manner, even if the actual physical devices differs (disk file, keyboard, network socket)

Types of streams

Java defines two types of streams


Byte streams (used to read/write binary data) Character streams (used to read/write characters, its uses Unicode)

Byte stream classes: At the top are two abstract classes,


InputStream OutputStream Their concrete subclasses handle the differences between various devices and implements (overrides) key abstract methods, such as read( ) and write( )

Character Stream Classes


At the top are two abstract classes,
Reader Writer

They have also some concrete subclasses that overrides key methods, such as read( ) and write( )

The Predefined streams


java.lang package (automatically imported) defines a class called System System contains three predefined public static stream variables, in, out, and err, which can be accessed from any part of the program without reference to a specific System object System.out refers to standard output stream (console) and System.in refers to standard input (keyboard)

Example

Reading Strings

End

You might also like