SlideShare a Scribd company logo
Input Output
Submitted To :
Falguni Roy,
Lecturer , IIT, NSTU.
Presented By :
Fazle Rabbi (ASH1825004M)
Al Shahriar Priyo (ASH1825020M)
Md. Saifur Rahman (ASH1825031M)
Faizul Karim Pathan (ASH1825033M)
Contents
Input /Output
Stream
FileOutputStreamClass
FileInputStreamClass
BufferOutputStreamClass
BufferInputStreamClass
SequenceInputStreamClass
FileWriter
FileReader
Console
FilePermission
File
FileDescriptor
PushBackReaderClass
StringWriterClass
StringReaderClass
Serialization
Example of Serialization
Advantage of Serialization
INPUT/OUTPUT
• Java I/O (Input and Output) is used to process the input and produce
the output.
• Java uses the concept of a stream to make I/O operation fast. The
java.io package contains all the classes required for input and output
operations.
• We can perform file handling in Java by Java I/O API.
STREAM
A stream is a sequence of data. In Java, a stream is composed of bytes. It's
called a stream because it is like a stream of water that continues to flow.
In Java, 3 streams are created for us automatically. All these streams are
attached with the console.
1) System.out : standard output stream
2) System.in: standard input stream
3) System.err : standard error stream
How to StreamWorks
FileOutputStream Class
• Java FileOutputStream is an output stream used for writing data to
a file.
• If you have to write primitive values into a file, use FileOutputStream
class.You can write byte-oriented as well as character-oriented data
through FileOutputStream class.
FileOutputStream class methods
Example :
FileInputStream Class
• Java FileInputStream class obtains input bytes from a file .
• It is used for reading byte-oriented data (streams of raw bytes) such as
image data, audio, video etc.
• also read character-stream data.
FileInputStream class methods
Example :
• Output :
Hi ,I amTrapped in IIT.
BufferedOutputStream Class
• Java BufferedOutputStream class is used for buffering an output
stream.
• It internally uses buffer to store data.
• It adds more efficiency than to write data directly into a stream.
• It makes the performance fast.
BufferedOutputStream class methods
Example :
BufferedInputStream Class
• Java BufferedInputStream class is used to read information from stream. It
internally uses buffer mechanism to make the performance fast.
• The important points about BufferedInputStream are:
• When the bytes from the stream are skipped or read, the internal buffer
automatically refilled from the contained input stream, many bytes at a time.
• When a BufferedInputStream is created, an internal buffer array is created.
BufferedInputStream class methods
Example :
SequenceInputStream Class
 Java SequenceInputStream class is used to read data from
multiple streams. It reads data sequentially (one by one).
 Methods of SequenceInputStream class :
Example :
FileWriter Class
• Java FileWriter class is used to write character-oriented data to a file.
• It is character-oriented class which is used for file handling in java.
• FileWriter is useful to create a file writing characters into it.
Methods of FileWriter
Example :
FileReader
• Java FileReader class is used to read data from the file
• FileReader is useful to read data in the form of characters from a ‘text’ file.
• The java FileReader class works much like the FileInputStream except the
FileInputstream reads bytes, whereas the FileReader reads character.
Methods of FileReader class
Example :
Console
• The Java Console class is be used to get input from console.
• It provides methods to read texts and passwords.
• If you read password using Console class, it will not be displayed to the
user.
Console class methods
FilePermission
• Java FilePermission class contains the permission related to a directory or file.
• All the permissions are related with path.
• The path can be of two types:
• D:IO-: It indicates that the permission is associated with all
sub directories and files recursively.
• D:IO*: It indicates that the permission is associated with all
directory and files within this directory excluding sub
directories.
Methods of FilePermission
File
• The File class is an abstract representation of file and directory pathname.
• A pathname can be either absolute or relative
• The File class have several methods for working with directories and files such
as creating new directories or files, deleting and renaming directories or files,
listing the contents of a directory etc
FileDescriptor
• FileDescriptor class serves as an handle to the underlying machine-
specific structure representing an open file, an open socket, or another
source or sink of bytes.
• The handle can be err, in or out.
• The FileDescriptor class is used to create
a FileInputStream or FileOutputStream to contain it.
PushbackReader Class
PushbackReader class is a character stream reader. It is used to pushes back a
character into stream and overrides the FilterReader class.
Class declaration
public class PushbackReader extends FilterReader
StringWriter Class
Java StringWriter class is a character stream that collects output from string
buffer, which can be used to construct a string. The StringWriter class
inherits the Writer class.
Class declaration:
public class StringWriter extends Writer
StringReader Class
StringReader class is a character stream with string as a source. It takes an
input string and changes it into character stream. It inherits Reader class.
Class declaration:
public class StringReader extends Reader
What is Serialization?
• Serialization in Java is a mechanism of writing the state of an object into a
byte stream.
• It is mainly used in Hibernate, RMI, JPA, EJB and JMS technologies.
• The reverse operation of serialization is called deserialization
java.io.Serializable interface
• Serializable is an interface
• The Cloneable and Remote are also interfaces.
• It must be implemented by the class whose object you want to persist.
Example of implements Serializable interface
Example of Java Serialization
Advantages of Java Serialization
• It is mainly used to travel object's state on the network
• Built into the system:You don't need to rely on third-party tools, libraries,
or configuration.
• Relatively simple to understand, at least in the beginning.
• Every developer knows it (or should). Regardless of whether Java devs
approve or disapprove, they are likely to be familiar with serialising Java
objects.
Input & output

More Related Content

PPT
Java IO Package and Streams
PPT
Various io stream classes .47
PPT
Character stream classes introd .51
PDF
input/ output in java
PPTX
Java Input Output (java.io.*)
PPT
Input output streams
PPT
Byte stream classes.49
PDF
java.io - streams and files
Java IO Package and Streams
Various io stream classes .47
Character stream classes introd .51
input/ output in java
Java Input Output (java.io.*)
Input output streams
Byte stream classes.49
java.io - streams and files

What's hot (20)

PPTX
L21 io streams
PPT
Java Streams
PPT
Character stream classes .52
PDF
Java Course 8: I/O, Files and Streams
PPT
IO and serialization
PDF
Java I/o streams
PPTX
File Handling in Java Oop presentation
PDF
Javaiostream
PPTX
Understanding java streams
PDF
Basic i/o & file handling in java
PDF
Java IO
PPT
Introducing object oriented programming (oop)
PPT
Java stream
ODP
IO In Java
PPTX
Java input output package
PPTX
OOPS – General Understanding in .NET
PPTX
Java stereams
PPT
7. Multithreading
PPTX
Input output files in java
PPTX
L21 io streams
Java Streams
Character stream classes .52
Java Course 8: I/O, Files and Streams
IO and serialization
Java I/o streams
File Handling in Java Oop presentation
Javaiostream
Understanding java streams
Basic i/o & file handling in java
Java IO
Introducing object oriented programming (oop)
Java stream
IO In Java
Java input output package
OOPS – General Understanding in .NET
Java stereams
7. Multithreading
Input output files in java
Ad

Similar to Input & output (20)

PDF
inputoutputstreams-140612032817-phpapp02.pdf
PPTX
32sql server
PPT
9. Input Output in java
PPTX
CHAPTER 5 mechanical engineeringasaaa.pptx
PPT
Various io stream classes .47
PPTX
Java program file I/O
PPTX
31cs
PPTX
oop unit1.pptx
PPTX
Buffer and scanner
PPTX
Chapter 13_m5JAVANOTESAPPLETS,INPUT.pptx
PPSX
Java IO, Serialization
PPTX
Session 22 - Java IO, Serialization
PPTX
PDF
PPT
web programming-Multithreading concept in Java.ppt
PPTX
Unit No 5 Files and Database Connectivity.pptx
PPTX
Computer science input and output BASICS.pptx
PPT
Presentation on java
PDF
Basic IO
inputoutputstreams-140612032817-phpapp02.pdf
32sql server
9. Input Output in java
CHAPTER 5 mechanical engineeringasaaa.pptx
Various io stream classes .47
Java program file I/O
31cs
oop unit1.pptx
Buffer and scanner
Chapter 13_m5JAVANOTESAPPLETS,INPUT.pptx
Java IO, Serialization
Session 22 - Java IO, Serialization
web programming-Multithreading concept in Java.ppt
Unit No 5 Files and Database Connectivity.pptx
Computer science input and output BASICS.pptx
Presentation on java
Basic IO
Ad

More from SAIFUR RAHMAN (7)

PPTX
Hash Function(Grostl) and Contex Hull Research paper
PPTX
DepenDNS Analysis
PPTX
Student Management System
PPTX
Exception handling
PPTX
Recommendation system
PPTX
Function
PPTX
Discrete math (sets)
Hash Function(Grostl) and Contex Hull Research paper
DepenDNS Analysis
Student Management System
Exception handling
Recommendation system
Function
Discrete math (sets)

Recently uploaded (20)

PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
web development for engineering and engineering
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
Geodesy 1.pptx...............................................
PPTX
Welding lecture in detail for understanding
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
PPT on Performance Review to get promotions
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPT
Mechanical Engineering MATERIALS Selection
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
web development for engineering and engineering
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Foundation to blockchain - A guide to Blockchain Tech
Geodesy 1.pptx...............................................
Welding lecture in detail for understanding
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPT on Performance Review to get promotions
OOP with Java - Java Introduction (Basics)
Automation-in-Manufacturing-Chapter-Introduction.pdf
Mechanical Engineering MATERIALS Selection
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
bas. eng. economics group 4 presentation 1.pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
CYBER-CRIMES AND SECURITY A guide to understanding
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf

Input & output