0% found this document useful (0 votes)
11 views13 pages

6 3 2 P 603ca00c90d8c File

The document discusses input stream classes in Java. It defines input stream as an abstract class for reading raw bytes from a stream. It covers the classification of input stream classes and some common methods of input stream classes like read(), close(), mark(), reset() etc.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views13 pages

6 3 2 P 603ca00c90d8c File

The document discusses input stream classes in Java. It defines input stream as an abstract class for reading raw bytes from a stream. It covers the classification of input stream classes and some common methods of input stream classes like read(), close(), mark(), reset() etc.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

CO_IF_22412_CO6

Mr. Siddhesh Ashok Vaidya, Lecturer, Vidyalankar Polytechnic

Date: 16th February 2021

Learning at your doorstep


Unit 6:
Managing Input/Output Files in Java

Written by

Siddhesh Ashok Vaidya


Lecturer, Department of Computer Engineering (NBA Accredited),
Vidyalankar Polytechnic, Mumbai
Unit Outcome 3b: Write programs
for reading and writing bytes to and
from the given files.
Learning Outcome 3c: Student should
understand the concept of Input
Stream Class
What we will learn today

1. Concept of Input Stream Classes Key takeaways


2. Classification of Input Stream Classes Concept and classification of stream classes
Some methods of stream classes
3. Methods of Input Stream Classes

Siddhesh Ashok Vaidya


Lecturer, Department of Computer Engineering (NBA Accredited), Vidyalankar Polytechnic,
Mumbai

Page 5 Maharashtra State Board of Technical Education


Concept Map

InputStream Classes

Page 6 Maharashtra State Board of Technical Education


Learning Objective/Key learning

► Understand concept of Input Stream Classes

Page 7 Maharashtra State Board of Technical Education


Concept Explanation: Input Stream Classes

 java.io.InputStream is an abstract class that contains the basic methods for reading raw bytes of data
from a stream.
 The InputStream class defines methods for performing the input functions like:
 reading bytes

 closing streams

 marking positions in streams


 skipping ahead in a stream
 finding the number of bytes in a stream

Page 8 Maharashtra State Board of Technical Education


Concept Explanation: InputStream Class Stream Hierarchy

Page 9 Maharashtra State Board of Technical Education


Concept Explanation: InputStream Class Methods

 int read ()
Returns an integer representation of next available byte of input.
-1 is returned at the stream end.

 int read (byte buffer[ ])


Read up to buffer.length bytes into buffer & returns actual number of bytes that are read.
At the end returns –1.

 int read (byte buffer[ ], int offset, int numbytes)


Attempts to read up to numbytes bytes into buffer starting at buffer[offset].
Returns actual number of bytes that are read.
At the end returns –1.

 void close ()
to close the input stream.

Page 10 Maharashtra State Board of Technical Education


Concept Explanation: InputStream Class Methods (contd.)

 void mark (int numbytes)


places a mark at current point in input stream and remain valid till number of bytes are read.

 void reset ()
Resets pointer to previously set mark/ goes back to stream beginning.

 long skip (long numbytes)


skips number of bytes.

 int available ()
Returns number of bytes currently available for reading.

Page 11 Maharashtra State Board of Technical Education


Quick Revision
► ____________is an abstract class that contains the basic methods for reading raw bytes of data from a
stream.
a) Bits
b) Bytes
c) java.io.InputStream
d) None of these

Ans: java.io.InputStream

► The following functions are performed by InputStream class.


a) Reading bytes
b) Closing streams
c) Skipping ahead in streams
d) All of the above

Ans: All of the above


Page 12 Maharashtra State Board of Technical Education
Summary

► InputStream Classes
► Class Hierarchy of InputStream Class
► Methods of InputStream Class

Page 13 Maharashtra State Board of Technical Education

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy