0% found this document useful (0 votes)
3 views6 pages

Java BufferedInputStream Overview

Uploaded by

japariciofdez
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)
3 views6 pages

Java BufferedInputStream Overview

Uploaded by

japariciofdez
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

21/9/23, 9:46 Java BufferedInputStream Class - javatpoint

Java 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.

Java BufferedInputStream class declaration


Let's see the declaration for [Link] class:

public class BufferedInputStream extends FilterInputStream

Java BufferedInputStream class constructors

Constructor Description

BufferedInputStream(InputStream IS) It creates the BufferedInputStream and saves it


argument, the input stream IS, for later use.

BufferedInputStream(InputStream IS, It creates the BufferedInputStream with a specified buffer


int size) size and saves it argument, the input stream IS, for later
use.

Java BufferedInputStream class methods

Method Description

int available() It returns an estimate number of bytes that can be read from the input
stream without blocking by the next invocation method for the input
stream.

int read() It read the next byte of data from the input stream.

[Link] 2/7
21/9/23, 9:46 Java BufferedInputStream Class - javatpoint

int read(byte[] b, int It read the bytes from the specified byte-input stream into a specified
off, int ln) byte array, starting with the given offset.

void close() It closes the input stream and releases any of the system resources
associated with the stream.

void reset() It repositions the stream at a position the mark method was last called
on this input stream.

void mark(int It sees the general contract of the mark method for the input stream.
readlimit)

long skip(long x) It skips over and discards x bytes of data from the input stream.

boolean It tests for the input stream to support the mark and reset methods.
markSupported()

Example of Java BufferedInputStream

Let's see the simple example to read data of file using BufferedInputStream:

package [Link];

import [Link].*;
public class BufferedInputStreamExample{
public static void main(String args[]){
try{
FileInputStream fin=new FileInputStream("D:\\[Link]");
BufferedInputStream bin=new BufferedInputStream(fin);
int i;

[Link] 3/7
21/9/23, 9:46 Java BufferedInputStream Class - javatpoint

while((i=[Link]())!=-1){
[Link]((char)i);
}
[Link]();
[Link]();
}catch(Exception e){[Link](e);}
}
}

Here, we are assuming that you have following data in "[Link]" file:

javaTpoint

Output:

javaTpoint

← Prev Next →

AD

For Videos Join Our Youtube Channel: Join Now

Feedback

Send your Feedback to feedback@[Link]

[Link] 4/7
21/9/23, 9:46 Java BufferedInputStream Class - javatpoint

Help Others, Please Share

Learn Latest Tutorials

Splunk SPSS Swagger Transact-SQL

Tumblr tutorial React tutorial Regex tutorial Reinforcement


learning tutorial
Tumblr ReactJS Regex
Reinforcement
Learning

R Programming RxJS tutorial React Native Python Design


tutorial tutorial Patterns
RxJS
R Programming React Native Python Design
Patterns

Python Pillow Python Turtle Keras tutorial


tutorial tutorial
Keras
Python Pillow Python Turtle

Preparation

Aptitude Logical Verbal Ability Interview


Reasoning Questions
Aptitude Verbal Ability
Reasoning Interview Questions

Company
Interview
Questions
Company Questions

[Link] 5/7
21/9/23, 9:46 Java BufferedInputStream Class - javatpoint

Trending Technologies

Artificial AWS Tutorial Selenium Cloud


Intelligence tutorial Computing
AWS
Artificial Selenium Cloud Computing
Intelligence

Hadoop tutorial ReactJS Data Science Angular 7


Tutorial Tutorial Tutorial
Hadoop
ReactJS Data Science Angular 7

Blockchain Git Tutorial Machine DevOps


Tutorial Learning Tutorial Tutorial
Git
Blockchain Machine Learning DevOps

[Link] / MCA

DBMS tutorial Data Structures DAA tutorial Operating


tutorial System
DBMS DAA
Data Structures Operating System

Computer Compiler Computer Discrete


Network tutorial Design tutorial Organization and Mathematics
Architecture Tutorial
Computer Network Compiler Design
Computer Discrete
Organization Mathematics

Ethical Hacking Computer Software html tutorial


Graphics Tutorial Engineering
Ethical Hacking Web Technology
Computer Graphics Software
Engineering

Cyber Security Automata C Language C++ tutorial


tutorial Tutorial tutorial
C++
[Link] 6/7
21/9/23, 9:46 Java BufferedInputStream Class - javatpoint

Cyber Security Automata C Programming

Java tutorial .Net Python tutorial List of


Framework Programs
Java Python
tutorial
Programs
.Net

Control Data Mining Data


Systems tutorial Tutorial Warehouse
Tutorial
Control System Data Mining
Data Warehouse

AD

[Link] 7/7

You might also like