SlideShare a Scribd company logo
Welcome to Ducat India
Language | Industrial Training | Digital Marketing | Web Technology |
Testing+ | Database | Networking |
Mobile Application | ERP | Graphic | Big Data | Cloud Computing
Apply Now
Call us:
70-70-90-50-90
www.ducatindia.com
Training & Certification
Java Input / Output
In Java, Input and Output (I/O) is used to process the input and produce the output.
This means an input stream can abstract many different input kinds: from a disk file, a keyboard or a network
socket. Likewise, an output stream may refer to the console, a disk file, or a network connection.
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 in the same manner, even if the actual physical devices to which they are linked differ. Thus,
the same I/O classes and methods can be applied to any device.
Streams are a clean way to deal with input/output without having every part of our code understand the
difference between a keyboard and a network, for example. Java implements streams within class hierarchies
defined in the java.io package.
The concept of sending data from one stream to another (like one pipe feeding into another pipe) has made
streams in Java a powerful tool for file processing. We can build a complex file processing sequence using a
series of simple stream operations.
This feature can be used to filter data along the pipeline of streams so that we obtain data in the desired format.
For example, we can use one stream to get raw data in binary format and then use another stream in series to
convert it into integers.
Input and Output Streams:-
Java streams are classified into two basic types: usually input streams and output streams. An input stream
extracts (i.e. reads) data from the source and sends it to the program.
The program connects and opens an input stream on the data source and then reads the data serially. Similarly,
the program connects and opens an output stream to the destination place of data and writes data out serially. In
both cases, the program does not know the details of endpoints (i.e. source and destination).
Byte Streams and Character Streams-
Java2 defines two types of streams: Byte and Character. Byte streams provide a convenient means for handling
input and output of bytes. Byte streams are used, for example, when reading or writing binary data. Character
streams offer a convenient means for controlling input and output of character.
They use Unicode and therefore, can be internationalized. Also, in some cases, character streams are more
efficient than byte streams. The original version of Java (Java 1.0) did not include character streams, and this, all
I/O was byte-oriented.
Character streams were added by Java 1.1, and certain byte-oriented classes and methods were deprecated.
Note:
At the lowest level, all I/O is still byte-oriented. The character-based streams provide a convenient and efficient
means for handling characters.
These two groups may be further classified base on their purposes. Byte Stream and Character Stream classes
contain specialized classes to deal with input and output operations independently on various devices.
We can also cross-group the streams based on the type of source or destination they read from or write to. The
source or goal may be a memory, a file or a pipe.
Overview of Byte Stream Classes:-
Byte stream classes are defined by using two-class hierarchies. At the top are two abstract classes:
(1) InputStream and (2) OutputStream
These abstract classes have several concrete subclasses that handle the differences between various devices, such
as disk files, network connections and even memory buffers.
InputStream class:-
InputStream classes used to read 8-bit bytes include a superclass known as InputStream and several sub-classes
to support various input-related functions.
The superclass InputStream is an abstract class, which defines methods for performing input functions such as:
Reading bytes.
Closing stream.
Marking positions in streams.
Skipping ahead in a stream.
Finding the number of bytes in a stream.
Methods of InputStream class:
int available()
Gives the number of bytes available in the input (must be overridden by the subclasses). The available method for
class InputStream always returns 0.
void close()
Closes this input stream and releases any system resources associated with the stream. The close method of
InputStream does nothing.
void mark(int readlimit)
Marks the current position in this input stream. The mark method of InputStream does nothing.
boolean markSupported()
Tests if this input stream supports the mark and resets methods. The markSupported method of InputStream
returns false.
abstract int read()
Reads the next byte of data from the input stream. A subclass must provide an implementation of this method.
int read(byte[] b)
Reads some number of bytes from the input stream and stores them into the buffer array b. The number of bytes
actually read is returned as an integer.
int read(byte[] b, int offset, int len)
Reads some bytes from the input stream and stores them into the buffer array b starting from position specified
by the parameter. The number of bytes reads it returned as an integer.
void reset()
Repositions this stream to the position when the mark method was last called on this input stream. The reset
method of InputStream does nothing and always throws IOException.
long skip(long n)
Skips over and discards upto n bytes of data from this input stream and returns the number of bytes skipped.
The DataInput Interface:
The DataInput is an interface, which defines methods for reading primitives from an InputStream.
Methods of DataInput Interface:
boolean readBoolean()
Reads one input byte and returns true if that byte is non-zero and false if that byte is zero.
byte readByte()
Reads and returns one byte input.
char readChar()
Reads an input character and returns its value.
double readDouble()
Reads eight input bytes and returns a double value.
float readfloat()
Reads four input bytes and returns a double value.
void readFully(byte[] b)
Reads some bytes from an input stream and stores them in a buffer array b. This method throws EOFException if
this stream reaches the end before reading all the bytes.
void readFully(byte[] b, int off, int len)
Reads len bytes from an input stream and stores them in a buffer array b starting at the position specified by the
off. This method throws EOFException if this stream reaches the end before reading all the bytes.
int readInt()
Reads four input bytes and returns an int value.
String readLine()
Reads the next line from the input stream.
long readLong()
Reads eight input bytes and returns a long value.
short readShort()
Reads two input bytes and returns a short value Strig readUTF( ) Reads in a string that has been encoded using a
modified UTF-8 format.
int skipBytes(int n)
Attempt to skip over n bytes of data from the input stream, discarding the skipped bytes. The actual number of
bytes skipped is returned.
OutputStream classes-
Output stream classes are derived from the base class OutputStream, an abstract class and have many sub-classes
for supporting various output-related functions.
The OutputStream class:-
The superclass OutputStream is an abstract class, which defines methods for performing output functions such as:
Writing bytes
Closing streams
Flushing streams
Methods of OutputStream Class:-
void close()
Closes this output stream and releases any stream resources associated with this stream.
void flush()
Flushes this output stream and forces any buffered output bytes to be written out.
void write(byte[] b)
Writes b. length bytes from the specified byte array to its output stream.
void write(byte[] b, int off, int len)
Writes len bytes from the specified byte array starting at offset off to its output stream.
abstract void write( int b)
Writes the specified byte to its output stream.
The DataOutput Interface:-
The DataOutput is an interface, which defines methods for writing primitives to an OutputStream.
Methods of DataOutput Interface:
void writeBoolean(boolean v)
Writes a boolean value to its output stream.
void writeByte(int v)
Writes to the output stream the eight low- order bits of the argument v.
void writeBytes(string s)
Writes the string to the output stream. For every character in the string s, taken in order, one byte is written to the
output stream.
void writeChar(int v)
Writes a character value, which is comprised of two bytes, to the output stream.
void writeChars(string s)
The output stream writes every character in the string s in the order of eight bytes.
void writeDouble(double v)
Writes a double value, which is comprised of eight bytes, to the output stream.
void writeFloat(float v)
Writes a float value, which is comprised of four bytes, to the output stream.
void writeInt(int v)
Writes a int value, which is comprised of four bytes, to the output stream.
void writeLong(long v)
Writes a long value, which is comprised of eight bytes, to the output stream.
void writeShort(int v)
Writes a short value, which is comprised of two bytes, to the output stream.
void writeUTF(String str)
Writes two bytes of length information to the output stream, followed by the modified UTF-8 representation of
every character in the string s.
Thanks You!!
Language | Industrial Training | Digital Marketing | Web Technology |
Testing+ | Database | Networking |
Mobile Application | ERP | Graphic | Big Data | Cloud Computing
Apply Now
Call us:
70-70-90-50-90
www.ducatindia.com
Training & Certification

More Related Content

What's hot (20)

IO In Java
IO In JavaIO In Java
IO In Java
parag
 
Java Streams
Java StreamsJava Streams
Java Streams
M Vishnuvardhan Reddy
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
siragezeynu
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streams
Shahjahan Samoon
 
Stream Based Input Output
Stream Based Input OutputStream Based Input Output
Stream Based Input Output
Bharat17485
 
Javaiostream
JavaiostreamJavaiostream
Javaiostream
Manav Prasad
 
Serial comm matlab
Serial comm matlabSerial comm matlab
Serial comm matlab
Anwar Hassan Ibrahim, PhD
 
Using Input Output
Using Input OutputUsing Input Output
Using Input Output
raksharao
 
Io streams
Io streamsIo streams
Io streams
Elizabeth alexander
 
Java Input Output (java.io.*)
Java Input Output (java.io.*)Java Input Output (java.io.*)
Java Input Output (java.io.*)
Om Ganesh
 
Java OOP Concepts 1st Slide
Java OOP Concepts 1st SlideJava OOP Concepts 1st Slide
Java OOP Concepts 1st Slide
sunny khan
 
Java IO
Java IOJava IO
Java IO
UTSAB NEUPANE
 
L21 io streams
L21 io streamsL21 io streams
L21 io streams
teach4uin
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
Debasish Pratihari
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
Prof. Dr. K. Adisesha
 
9 Inputs & Outputs
9 Inputs & Outputs9 Inputs & Outputs
9 Inputs & Outputs
Deepak Hagadur Bheemaraju
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
Hamid Ghorbani
 
Class notes(week 5) on command line arguments
Class notes(week 5) on command line argumentsClass notes(week 5) on command line arguments
Class notes(week 5) on command line arguments
Kuntal Bhowmick
 
Character stream classes .52
Character stream classes .52Character stream classes .52
Character stream classes .52
myrajendra
 
File Handling
File HandlingFile Handling
File Handling
TusharBatra27
 

Similar to Java Input and Output (20)

Web Technology Web Technology Notes Streams Network Principles and SocketsUni...
Web Technology Web Technology Notes Streams Network Principles and SocketsUni...Web Technology Web Technology Notes Streams Network Principles and SocketsUni...
Web Technology Web Technology Notes Streams Network Principles and SocketsUni...
uthayashangar1
 
Stream In Java.pptx
Stream In Java.pptxStream In Java.pptx
Stream In Java.pptx
ssuser9d7049
 
11_Str11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.eams.pdf
11_Str11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.eams.pdf11_Str11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.eams.pdf
11_Str11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.eams.pdf
hungvidien123
 
UNIT4-IO,Generics,String Handling.pdf Notes
UNIT4-IO,Generics,String Handling.pdf NotesUNIT4-IO,Generics,String Handling.pdf Notes
UNIT4-IO,Generics,String Handling.pdf Notes
SakkaravarthiS1
 
IOStream.pptx
IOStream.pptxIOStream.pptx
IOStream.pptx
HindAlmisbahi
 
Io stream
Io streamIo stream
Io stream
mallica19
 
Java development development Files lectur6.ppt
Java development development Files lectur6.pptJava development development Files lectur6.ppt
Java development development Files lectur6.ppt
rafeakrafeak
 
Java IO Package and Streams
Java IO Package and StreamsJava IO Package and Streams
Java IO Package and Streams
babak danyal
 
Md121 streams
Md121 streamsMd121 streams
Md121 streams
Rakesh Madugula
 
Basic IO
Basic IOBasic IO
Basic IO
Ravi_Kant_Sahu
 
Java Day-6
Java Day-6Java Day-6
Java Day-6
People Strategists
 
CHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptxCHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptx
SadhilAggarwal
 
CSE3146-ADV JAVA M2.pdf
CSE3146-ADV JAVA M2.pdfCSE3146-ADV JAVA M2.pdf
CSE3146-ADV JAVA M2.pdf
VithalReddy3
 
Monhocvecaujahetvagiuplaptunhhayhonha.pdf
Monhocvecaujahetvagiuplaptunhhayhonha.pdfMonhocvecaujahetvagiuplaptunhhayhonha.pdf
Monhocvecaujahetvagiuplaptunhhayhonha.pdf
cuchuoi83ne
 
javaiostream
javaiostreamjavaiostream
javaiostream
Arjun Shanka
 
Jstreams
JstreamsJstreams
Jstreams
Shehrevar Davierwala
 
Java basics
Java basicsJava basics
Java basics
Jitender Jain
 
IOstreams hgjhsgfdjyggckhgckhjxfhbuvobunciu
IOstreams hgjhsgfdjyggckhgckhjxfhbuvobunciuIOstreams hgjhsgfdjyggckhgckhjxfhbuvobunciu
IOstreams hgjhsgfdjyggckhgckhjxfhbuvobunciu
akinbhattarai1
 
Java session14
Java session14Java session14
Java session14
Niit Care
 
Iostreams
IostreamsIostreams
Iostreams
aptechsravan
 
Web Technology Web Technology Notes Streams Network Principles and SocketsUni...
Web Technology Web Technology Notes Streams Network Principles and SocketsUni...Web Technology Web Technology Notes Streams Network Principles and SocketsUni...
Web Technology Web Technology Notes Streams Network Principles and SocketsUni...
uthayashangar1
 
Stream In Java.pptx
Stream In Java.pptxStream In Java.pptx
Stream In Java.pptx
ssuser9d7049
 
11_Str11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.eams.pdf
11_Str11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.eams.pdf11_Str11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.eams.pdf
11_Str11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.eams.pdf
hungvidien123
 
UNIT4-IO,Generics,String Handling.pdf Notes
UNIT4-IO,Generics,String Handling.pdf NotesUNIT4-IO,Generics,String Handling.pdf Notes
UNIT4-IO,Generics,String Handling.pdf Notes
SakkaravarthiS1
 
Java development development Files lectur6.ppt
Java development development Files lectur6.pptJava development development Files lectur6.ppt
Java development development Files lectur6.ppt
rafeakrafeak
 
Java IO Package and Streams
Java IO Package and StreamsJava IO Package and Streams
Java IO Package and Streams
babak danyal
 
CHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptxCHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptx
SadhilAggarwal
 
CSE3146-ADV JAVA M2.pdf
CSE3146-ADV JAVA M2.pdfCSE3146-ADV JAVA M2.pdf
CSE3146-ADV JAVA M2.pdf
VithalReddy3
 
Monhocvecaujahetvagiuplaptunhhayhonha.pdf
Monhocvecaujahetvagiuplaptunhhayhonha.pdfMonhocvecaujahetvagiuplaptunhhayhonha.pdf
Monhocvecaujahetvagiuplaptunhhayhonha.pdf
cuchuoi83ne
 
IOstreams hgjhsgfdjyggckhgckhjxfhbuvobunciu
IOstreams hgjhsgfdjyggckhgckhjxfhbuvobunciuIOstreams hgjhsgfdjyggckhgckhjxfhbuvobunciu
IOstreams hgjhsgfdjyggckhgckhjxfhbuvobunciu
akinbhattarai1
 
Java session14
Java session14Java session14
Java session14
Niit Care
 
Ad

More from Ducat India (20)

Join MCSA Server 2016 And 2019 Course In Noida
Join MCSA Server 2016 And 2019 Course In NoidaJoin MCSA Server 2016 And 2019 Course In Noida
Join MCSA Server 2016 And 2019 Course In Noida
Ducat India
 
Apply now for dot net training classes in Noida
Apply now for dot net training classes in NoidaApply now for dot net training classes in Noida
Apply now for dot net training classes in Noida
Ducat India
 
Apply now for linux training classes in noida
Apply now for linux training classes in noidaApply now for linux training classes in noida
Apply now for linux training classes in noida
Ducat India
 
Apply Now for DevOps Training Classes in Noida
Apply Now for DevOps Training Classes in NoidaApply Now for DevOps Training Classes in Noida
Apply Now for DevOps Training Classes in Noida
Ducat India
 
Apply Now for AutoCAD Training Course in Noida
Apply Now for AutoCAD Training Course in NoidaApply Now for AutoCAD Training Course in Noida
Apply Now for AutoCAD Training Course in Noida
Ducat India
 
Amazon Elastic Load Balancing
Amazon Elastic Load BalancingAmazon Elastic Load Balancing
Amazon Elastic Load Balancing
Ducat India
 
AWS Relation Database Services
AWS Relation Database ServicesAWS Relation Database Services
AWS Relation Database Services
Ducat India
 
Microsoft Dynamics CRM – Web Resources
Microsoft Dynamics CRM – Web ResourcesMicrosoft Dynamics CRM – Web Resources
Microsoft Dynamics CRM – Web Resources
Ducat India
 
Field Types
Field TypesField Types
Field Types
Ducat India
 
Sprint in jira
Sprint in jiraSprint in jira
Sprint in jira
Ducat India
 
JIRA Versions
JIRA VersionsJIRA Versions
JIRA Versions
Ducat India
 
Kanban Board in Jira
Kanban Board in JiraKanban Board in Jira
Kanban Board in Jira
Ducat India
 
Test Report Preparation
Test Report PreparationTest Report Preparation
Test Report Preparation
Ducat India
 
What is Text Analysis?
What is Text Analysis?What is Text Analysis?
What is Text Analysis?
Ducat India
 
Data Science Using Scikit-Learn
Data Science Using Scikit-LearnData Science Using Scikit-Learn
Data Science Using Scikit-Learn
Ducat India
 
Struts 2 – Database Access
Struts 2 – Database AccessStruts 2 – Database Access
Struts 2 – Database Access
Ducat India
 
Struts 2 – Interceptors
Struts 2 – InterceptorsStruts 2 – Interceptors
Struts 2 – Interceptors
Ducat India
 
Struts 2 – Architecture
Struts 2 – ArchitectureStruts 2 – Architecture
Struts 2 – Architecture
Ducat India
 
Hibernate 5 – merge() Example
Hibernate 5 – merge() ExampleHibernate 5 – merge() Example
Hibernate 5 – merge() Example
Ducat India
 
Hibernate Object States – Transient,Persistent and Detached
Hibernate Object States – Transient,Persistent and DetachedHibernate Object States – Transient,Persistent and Detached
Hibernate Object States – Transient,Persistent and Detached
Ducat India
 
Join MCSA Server 2016 And 2019 Course In Noida
Join MCSA Server 2016 And 2019 Course In NoidaJoin MCSA Server 2016 And 2019 Course In Noida
Join MCSA Server 2016 And 2019 Course In Noida
Ducat India
 
Apply now for dot net training classes in Noida
Apply now for dot net training classes in NoidaApply now for dot net training classes in Noida
Apply now for dot net training classes in Noida
Ducat India
 
Apply now for linux training classes in noida
Apply now for linux training classes in noidaApply now for linux training classes in noida
Apply now for linux training classes in noida
Ducat India
 
Apply Now for DevOps Training Classes in Noida
Apply Now for DevOps Training Classes in NoidaApply Now for DevOps Training Classes in Noida
Apply Now for DevOps Training Classes in Noida
Ducat India
 
Apply Now for AutoCAD Training Course in Noida
Apply Now for AutoCAD Training Course in NoidaApply Now for AutoCAD Training Course in Noida
Apply Now for AutoCAD Training Course in Noida
Ducat India
 
Amazon Elastic Load Balancing
Amazon Elastic Load BalancingAmazon Elastic Load Balancing
Amazon Elastic Load Balancing
Ducat India
 
AWS Relation Database Services
AWS Relation Database ServicesAWS Relation Database Services
AWS Relation Database Services
Ducat India
 
Microsoft Dynamics CRM – Web Resources
Microsoft Dynamics CRM – Web ResourcesMicrosoft Dynamics CRM – Web Resources
Microsoft Dynamics CRM – Web Resources
Ducat India
 
Kanban Board in Jira
Kanban Board in JiraKanban Board in Jira
Kanban Board in Jira
Ducat India
 
Test Report Preparation
Test Report PreparationTest Report Preparation
Test Report Preparation
Ducat India
 
What is Text Analysis?
What is Text Analysis?What is Text Analysis?
What is Text Analysis?
Ducat India
 
Data Science Using Scikit-Learn
Data Science Using Scikit-LearnData Science Using Scikit-Learn
Data Science Using Scikit-Learn
Ducat India
 
Struts 2 – Database Access
Struts 2 – Database AccessStruts 2 – Database Access
Struts 2 – Database Access
Ducat India
 
Struts 2 – Interceptors
Struts 2 – InterceptorsStruts 2 – Interceptors
Struts 2 – Interceptors
Ducat India
 
Struts 2 – Architecture
Struts 2 – ArchitectureStruts 2 – Architecture
Struts 2 – Architecture
Ducat India
 
Hibernate 5 – merge() Example
Hibernate 5 – merge() ExampleHibernate 5 – merge() Example
Hibernate 5 – merge() Example
Ducat India
 
Hibernate Object States – Transient,Persistent and Detached
Hibernate Object States – Transient,Persistent and DetachedHibernate Object States – Transient,Persistent and Detached
Hibernate Object States – Transient,Persistent and Detached
Ducat India
 
Ad

Recently uploaded (20)

Nice Dream.pdf /
Nice Dream.pdf                              /Nice Dream.pdf                              /
Nice Dream.pdf /
ErinUsher3
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18
Celine George
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptxPests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Arshad Shaikh
 
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
Quiz Club of PSG College of Arts & Science
 
Hemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptxHemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptx
Arshad Shaikh
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18
Celine George
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
GeorgeDiamandis11
 
Optimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptxOptimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptx
UrmiPrajapati3
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
EduSkills OECD
 
Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...
Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...
Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...
National Information Standards Organization (NISO)
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdfUnit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
Parenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independenceParenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independence
Pooky Knightsmith
 
Nice Dream.pdf /
Nice Dream.pdf                              /Nice Dream.pdf                              /
Nice Dream.pdf /
ErinUsher3
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18
Celine George
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptxPests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Arshad Shaikh
 
Hemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptxHemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptx
Arshad Shaikh
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18
Celine George
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
GeorgeDiamandis11
 
Optimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptxOptimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptx
UrmiPrajapati3
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
EduSkills OECD
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdfUnit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
Parenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independenceParenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independence
Pooky Knightsmith
 

Java Input and Output

  • 1. Welcome to Ducat India Language | Industrial Training | Digital Marketing | Web Technology | Testing+ | Database | Networking | Mobile Application | ERP | Graphic | Big Data | Cloud Computing Apply Now Call us: 70-70-90-50-90 www.ducatindia.com Training & Certification
  • 2. Java Input / Output In Java, Input and Output (I/O) is used to process the input and produce the output. This means an input stream can abstract many different input kinds: from a disk file, a keyboard or a network socket. Likewise, an output stream may refer to the console, a disk file, or a network connection. 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 in the same manner, even if the actual physical devices to which they are linked differ. Thus, the same I/O classes and methods can be applied to any device. Streams are a clean way to deal with input/output without having every part of our code understand the difference between a keyboard and a network, for example. Java implements streams within class hierarchies defined in the java.io package. The concept of sending data from one stream to another (like one pipe feeding into another pipe) has made streams in Java a powerful tool for file processing. We can build a complex file processing sequence using a series of simple stream operations.
  • 3. This feature can be used to filter data along the pipeline of streams so that we obtain data in the desired format. For example, we can use one stream to get raw data in binary format and then use another stream in series to convert it into integers. Input and Output Streams:- Java streams are classified into two basic types: usually input streams and output streams. An input stream extracts (i.e. reads) data from the source and sends it to the program. The program connects and opens an input stream on the data source and then reads the data serially. Similarly, the program connects and opens an output stream to the destination place of data and writes data out serially. In both cases, the program does not know the details of endpoints (i.e. source and destination). Byte Streams and Character Streams- Java2 defines two types of streams: Byte and Character. Byte streams provide a convenient means for handling input and output of bytes. Byte streams are used, for example, when reading or writing binary data. Character streams offer a convenient means for controlling input and output of character. They use Unicode and therefore, can be internationalized. Also, in some cases, character streams are more efficient than byte streams. The original version of Java (Java 1.0) did not include character streams, and this, all I/O was byte-oriented.
  • 4. Character streams were added by Java 1.1, and certain byte-oriented classes and methods were deprecated. Note: At the lowest level, all I/O is still byte-oriented. The character-based streams provide a convenient and efficient means for handling characters. These two groups may be further classified base on their purposes. Byte Stream and Character Stream classes contain specialized classes to deal with input and output operations independently on various devices. We can also cross-group the streams based on the type of source or destination they read from or write to. The source or goal may be a memory, a file or a pipe. Overview of Byte Stream Classes:- Byte stream classes are defined by using two-class hierarchies. At the top are two abstract classes: (1) InputStream and (2) OutputStream These abstract classes have several concrete subclasses that handle the differences between various devices, such as disk files, network connections and even memory buffers.
  • 5. InputStream class:- InputStream classes used to read 8-bit bytes include a superclass known as InputStream and several sub-classes to support various input-related functions. The superclass InputStream is an abstract class, which defines methods for performing input functions such as: Reading bytes. Closing stream. Marking positions in streams. Skipping ahead in a stream. Finding the number of bytes in a stream. Methods of InputStream class: int available() Gives the number of bytes available in the input (must be overridden by the subclasses). The available method for class InputStream always returns 0. void close() Closes this input stream and releases any system resources associated with the stream. The close method of InputStream does nothing.
  • 6. void mark(int readlimit) Marks the current position in this input stream. The mark method of InputStream does nothing. boolean markSupported() Tests if this input stream supports the mark and resets methods. The markSupported method of InputStream returns false. abstract int read() Reads the next byte of data from the input stream. A subclass must provide an implementation of this method. int read(byte[] b) Reads some number of bytes from the input stream and stores them into the buffer array b. The number of bytes actually read is returned as an integer. int read(byte[] b, int offset, int len) Reads some bytes from the input stream and stores them into the buffer array b starting from position specified by the parameter. The number of bytes reads it returned as an integer.
  • 7. void reset() Repositions this stream to the position when the mark method was last called on this input stream. The reset method of InputStream does nothing and always throws IOException. long skip(long n) Skips over and discards upto n bytes of data from this input stream and returns the number of bytes skipped. The DataInput Interface: The DataInput is an interface, which defines methods for reading primitives from an InputStream. Methods of DataInput Interface: boolean readBoolean() Reads one input byte and returns true if that byte is non-zero and false if that byte is zero. byte readByte() Reads and returns one byte input. char readChar() Reads an input character and returns its value. double readDouble() Reads eight input bytes and returns a double value.
  • 8. float readfloat() Reads four input bytes and returns a double value. void readFully(byte[] b) Reads some bytes from an input stream and stores them in a buffer array b. This method throws EOFException if this stream reaches the end before reading all the bytes. void readFully(byte[] b, int off, int len) Reads len bytes from an input stream and stores them in a buffer array b starting at the position specified by the off. This method throws EOFException if this stream reaches the end before reading all the bytes. int readInt() Reads four input bytes and returns an int value. String readLine() Reads the next line from the input stream. long readLong() Reads eight input bytes and returns a long value. short readShort() Reads two input bytes and returns a short value Strig readUTF( ) Reads in a string that has been encoded using a modified UTF-8 format.
  • 9. int skipBytes(int n) Attempt to skip over n bytes of data from the input stream, discarding the skipped bytes. The actual number of bytes skipped is returned. OutputStream classes- Output stream classes are derived from the base class OutputStream, an abstract class and have many sub-classes for supporting various output-related functions. The OutputStream class:- The superclass OutputStream is an abstract class, which defines methods for performing output functions such as: Writing bytes Closing streams Flushing streams Methods of OutputStream Class:- void close() Closes this output stream and releases any stream resources associated with this stream. void flush() Flushes this output stream and forces any buffered output bytes to be written out. void write(byte[] b) Writes b. length bytes from the specified byte array to its output stream.
  • 10. void write(byte[] b, int off, int len) Writes len bytes from the specified byte array starting at offset off to its output stream. abstract void write( int b) Writes the specified byte to its output stream. The DataOutput Interface:- The DataOutput is an interface, which defines methods for writing primitives to an OutputStream. Methods of DataOutput Interface: void writeBoolean(boolean v) Writes a boolean value to its output stream. void writeByte(int v) Writes to the output stream the eight low- order bits of the argument v. void writeBytes(string s) Writes the string to the output stream. For every character in the string s, taken in order, one byte is written to the output stream. void writeChar(int v) Writes a character value, which is comprised of two bytes, to the output stream. void writeChars(string s) The output stream writes every character in the string s in the order of eight bytes.
  • 11. void writeDouble(double v) Writes a double value, which is comprised of eight bytes, to the output stream. void writeFloat(float v) Writes a float value, which is comprised of four bytes, to the output stream. void writeInt(int v) Writes a int value, which is comprised of four bytes, to the output stream. void writeLong(long v) Writes a long value, which is comprised of eight bytes, to the output stream. void writeShort(int v) Writes a short value, which is comprised of two bytes, to the output stream. void writeUTF(String str) Writes two bytes of length information to the output stream, followed by the modified UTF-8 representation of every character in the string s.
  • 12. Thanks You!! Language | Industrial Training | Digital Marketing | Web Technology | Testing+ | Database | Networking | Mobile Application | ERP | Graphic | Big Data | Cloud Computing Apply Now Call us: 70-70-90-50-90 www.ducatindia.com Training & Certification