SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
Presented By:
Arif Ullah(2630)
Presented To:
Sir Fasee Ullah
ABASYN UNIVERSITY PESHAWAR
‱ Buffer :
‱ Introduction
‱ Stream
‱ Input & output buffered
‱ Example
‱ Scanner:
‱ Introduction
‱ Scanner class
‱ Methods
‱ Example
 The Java.io.BufferedReade class reads text from a character-input stream,
buffering characters so as to provide for the efficient reading of characters,
arrays, and lines. Following are the important points about Buffered
Reader:
 The buffer size may be specified, or the default size may be used.
 Each read request made of a Reader causes a corresponding read request
to be made of the underlying character or byte stream.
 A stream is a sequence of data. In Java a stream is composed of bytes. It's
called a stream because it's like a stream of water that continues to flow.
 Three streams are created for us automatically:
 1) System.out: standard output stream
 2) System.in: standard input stream
 3) System.err: standard error
 Input and Output in Java
Input and Output (I/O) is used to process the input
and produce the output based on the input. Java uses
the concept of stream to make I/O operations fast.
java.io package contains all the classes required for
input and output operations.
 Java application uses an output stream to write data to a destination, it may
be a file,an array,peripheral device or socket.
 Java application uses an input stream to read data from a source, it may be
a file,an array,peripheral device or socket.
 BufferedOutputStream used an internal buffer. It adds more efficiency than
to write data directly into a stream. So, it makes the performance fast.
 In the following example, we are writing the textual information in the Buffered
Output Stream object which is connected to the File Output Stream object. The
flush() flushes the data of one stream and send it into another. It is required if you
have connected the one stream with another.
‱ import java.io.*;
‱ class Test{
‱ public static void main(String args[])
‱ throws Exception{
‱ FileOutputStream fout=new FileOutputStream("f1.txt");
‱ BufferedOutputStream bout=new BufferedOutputStream(fout);
‱
‱ String s="Sachin is my favourite player";
‱ byte b[]=s.getBytes();
‱ bout.write(b);
‱
‱ bout.flush();
‱ bout.close();
‱ System.out.println("success");
‱ }
‱ }
‱ import java.io.*;
‱ class SimpleRead{
‱ public static void main(String args[]){
‱ try{
‱ FileInputStream fin=new FileInputStream("f1.txt");
‱ BufferedInputStream bin=new BufferedInputStream(fin);
‱ int i;
‱ while((i=bin.read())!=-1)
‱ System.out.println((char)i);
‱
‱ fin.close();
‱ }
‱ catch(Exception e){system.out.println(e);}
‱ }
‱ }
‱ Output:Sachin is my favourite player
‱
‱ Output:Sachin is my favourite player
 There are various ways to read input from the keyboard, the
java.util.Scanner class is one of them. The Scanner class breaks the
input into tokens using a delimiter which is whitespace bydefault. It
provides many methods to read and parse various primitive values.
 Allows the user to input the values of various types.
 Defined within a package java.util.
 import java.util.Scanner;
Creating scanner object
 Scanner sc = new Scanner(System.in);
 nextInt():
‱ receives the next token from scanner object which can be expressed as an
integer and stored in integer type
 nextFloat():
‱ receives the next token from scanner object which can be expressed as an
floating and stored in float type
 nextDouble():
‱ receives the next token from scanner object which can be expressed as an
double and stored in double type
 nextLine():
‱ receives the next line of the string
‱ package scanner;
‱ import java.util.Scanner;
‱ public class scannerDemo {
‱ void sum(int a, float b){
‱ double result=a+b;
‱ System.out.println("the sum is = "+result);
‱ }
‱ public static void main(String[] args){
‱ Scanner scanner=new Scanner(System.in);
‱ System.out.println("input integer value:");
‱ int num1=scanner.nextInt();
‱ System.out.println("input double value:");
‱ float num2=scanner.nextFloat();
‱ scannerDemo scannerDemo=new
scannerDemo();
‱ scannerDemo.sum(num1, num2);
‱ }
‱ }
‱ http://www.tutorialspoint.com/java/io/java_io_bufferedreader.htm
‱ http://www.slideshare.net/sonibabu/scanner-classes
‱ https://www.facebook.com/javatpoint
‱ http://www.javatpoint.com/cloud-computing-tutorial
Buffer and scanner

More Related Content

PPTX
Java package
PDF
Oops concepts || Object Oriented Programming Concepts in Java
PPTX
Virtual base class
PPTX
Overloading and overriding in vb.net
PPT
Scanner class
PPTX
Arrays in Java
PDF
Java Serialization
PPT
java swing
Java package
Oops concepts || Object Oriented Programming Concepts in Java
Virtual base class
Overloading and overriding in vb.net
Scanner class
Arrays in Java
Java Serialization
java swing

What's hot (20)

PPTX
Data types in java
PPTX
Classes, objects in JAVA
PPTX
Java awt (abstract window toolkit)
PPTX
Polymorphism in java
PPTX
Inheritance in JAVA PPT
PPTX
Ado.Net Tutorial
PDF
JavaScript - Chapter 8 - Objects
PDF
Java thread life cycle
PPT
Collection Framework in java
PDF
Java Linked List Tutorial | Edureka
PDF
JavaScript - Chapter 12 - Document Object Model
PPT
Classes&objects
PPTX
JAVA AWT
PPTX
Strings in Java
PPTX
Methods in java
PPTX
Exception handling in Java
PPTX
Member Function in C++
PPTX
I/O Streams
PPTX
Java constructors
Data types in java
Classes, objects in JAVA
Java awt (abstract window toolkit)
Polymorphism in java
Inheritance in JAVA PPT
Ado.Net Tutorial
JavaScript - Chapter 8 - Objects
Java thread life cycle
Collection Framework in java
Java Linked List Tutorial | Edureka
JavaScript - Chapter 12 - Document Object Model
Classes&objects
JAVA AWT
Strings in Java
Methods in java
Exception handling in Java
Member Function in C++
I/O Streams
Java constructors
Ad

Viewers also liked (16)

PPT
X$Tables And Sga Scanner, DOAG2009
 
PPTX
Java 8 Streams And Common Operations By Harmeet Singh(Taara)
PPTX
java: basics, user input, data type, constructor
PPTX
Define location of Preplaced cells(http://www.vlsisystemdesign.com/PD-Flow.php)
PPT
1 java - data type
PPT
ppt on scanner class
PDF
Jnp
 
PPTX
Understanding java streams
PDF
Java I/O
PPSX
Esoft Metro Campus - Certificate in java basics
PPT
Object-Oriented Analysis and Design
PPTX
Structured Vs, Object Oriented Analysis and Design
PPTX
automated teller machines
PPT
10 Slides to ATM
PPT
Object Oriented Analysis and Design
PPT
Atm System
X$Tables And Sga Scanner, DOAG2009
 
Java 8 Streams And Common Operations By Harmeet Singh(Taara)
java: basics, user input, data type, constructor
Define location of Preplaced cells(http://www.vlsisystemdesign.com/PD-Flow.php)
1 java - data type
ppt on scanner class
Jnp
 
Understanding java streams
Java I/O
Esoft Metro Campus - Certificate in java basics
Object-Oriented Analysis and Design
Structured Vs, Object Oriented Analysis and Design
automated teller machines
10 Slides to ATM
Object Oriented Analysis and Design
Atm System
Ad

Similar to Buffer and scanner (20)

PPTX
Stream In Java.pptx
PPT
Java development development Files lectur6.ppt
PPTX
Wk_10_Scanner and BufferedReader Class in Java.pptx
PPTX
L21 io streams
DOC
Web Technology Web Technology Notes Streams Network Principles and SocketsUni...
PPT
Java stream
PDF
UNIT4-IO,Generics,String Handling.pdf Notes
PPT
Using Input Output
PPTX
Java Input Output (java.io.*)
PPTX
Io streams
PPT
Javaio
PPT
Javaio
PPTX
Computer science input and output BASICS.pptx
PDF
Chapter 2.1 : Data Stream
DOCX
Unit IV Notes.docx
PPTX
Java I/O
PDF
IOstreams hgjhsgfdjyggckhgckhjxfhbuvobunciu
PPTX
Input & output
PPTX
Java Input and Output
PPTX
IOStream.pptx
Stream In Java.pptx
Java development development Files lectur6.ppt
Wk_10_Scanner and BufferedReader Class in Java.pptx
L21 io streams
Web Technology Web Technology Notes Streams Network Principles and SocketsUni...
Java stream
UNIT4-IO,Generics,String Handling.pdf Notes
Using Input Output
Java Input Output (java.io.*)
Io streams
Javaio
Javaio
Computer science input and output BASICS.pptx
Chapter 2.1 : Data Stream
Unit IV Notes.docx
Java I/O
IOstreams hgjhsgfdjyggckhgckhjxfhbuvobunciu
Input & output
Java Input and Output
IOStream.pptx

Recently uploaded (20)

PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
history of c programming in notes for students .pptx
PDF
Nekopoi APK 2025 free lastest update
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
ai tools demonstartion for schools and inter college
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PPTX
Transform Your Business with a Software ERP System
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
System and Network Administraation Chapter 3
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
medical staffing services at VALiNTRY
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
Navsoft: AI-Powered Business Solutions & Custom Software Development
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Wondershare Filmora 15 Crack With Activation Key [2025
history of c programming in notes for students .pptx
Nekopoi APK 2025 free lastest update
Softaken Excel to vCard Converter Software.pdf
How to Migrate SBCGlobal Email to Yahoo Easily
ai tools demonstartion for schools and inter college
Which alternative to Crystal Reports is best for small or large businesses.pdf
ManageIQ - Sprint 268 Review - Slide Deck
Transform Your Business with a Software ERP System
Design an Analysis of Algorithms I-SECS-1021-03
System and Network Administraation Chapter 3
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Design an Analysis of Algorithms II-SECS-1021-03
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
medical staffing services at VALiNTRY
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
How to Choose the Right IT Partner for Your Business in Malaysia

Buffer and scanner

  • 1. Presented By: Arif Ullah(2630) Presented To: Sir Fasee Ullah ABASYN UNIVERSITY PESHAWAR
  • 2. ‱ Buffer : ‱ Introduction ‱ Stream ‱ Input & output buffered ‱ Example ‱ Scanner: ‱ Introduction ‱ Scanner class ‱ Methods ‱ Example
  • 3.  The Java.io.BufferedReade class reads text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines. Following are the important points about Buffered Reader:  The buffer size may be specified, or the default size may be used.  Each read request made of a Reader causes a corresponding read request to be made of the underlying character or byte stream.
  • 4.  A stream is a sequence of data. In Java a stream is composed of bytes. It's called a stream because it's like a stream of water that continues to flow.  Three streams are created for us automatically:  1) System.out: standard output stream  2) System.in: standard input stream  3) System.err: standard error  Input and Output in Java Input and Output (I/O) is used to process the input and produce the output based on the input. Java uses the concept of stream to make I/O operations fast. java.io package contains all the classes required for input and output operations.
  • 5.  Java application uses an output stream to write data to a destination, it may be a file,an array,peripheral device or socket.
  • 6.  Java application uses an input stream to read data from a source, it may be a file,an array,peripheral device or socket.
  • 7.  BufferedOutputStream used an internal buffer. It adds more efficiency than to write data directly into a stream. So, it makes the performance fast.  In the following example, we are writing the textual information in the Buffered Output Stream object which is connected to the File Output Stream object. The flush() flushes the data of one stream and send it into another. It is required if you have connected the one stream with another.
  • 8. ‱ import java.io.*; ‱ class Test{ ‱ public static void main(String args[]) ‱ throws Exception{ ‱ FileOutputStream fout=new FileOutputStream("f1.txt"); ‱ BufferedOutputStream bout=new BufferedOutputStream(fout); ‱ ‱ String s="Sachin is my favourite player"; ‱ byte b[]=s.getBytes(); ‱ bout.write(b); ‱ ‱ bout.flush(); ‱ bout.close(); ‱ System.out.println("success"); ‱ } ‱ }
  • 9. ‱ import java.io.*; ‱ class SimpleRead{ ‱ public static void main(String args[]){ ‱ try{ ‱ FileInputStream fin=new FileInputStream("f1.txt"); ‱ BufferedInputStream bin=new BufferedInputStream(fin); ‱ int i; ‱ while((i=bin.read())!=-1) ‱ System.out.println((char)i); ‱ ‱ fin.close(); ‱ } ‱ catch(Exception e){system.out.println(e);} ‱ } ‱ } ‱ Output:Sachin is my favourite player ‱ ‱ Output:Sachin is my favourite player
  • 10.  There are various ways to read input from the keyboard, the java.util.Scanner class is one of them. The Scanner class breaks the input into tokens using a delimiter which is whitespace bydefault. It provides many methods to read and parse various primitive values.  Allows the user to input the values of various types.  Defined within a package java.util.
  • 11.  import java.util.Scanner; Creating scanner object  Scanner sc = new Scanner(System.in);
  • 12.  nextInt(): ‱ receives the next token from scanner object which can be expressed as an integer and stored in integer type  nextFloat(): ‱ receives the next token from scanner object which can be expressed as an floating and stored in float type
  • 13.  nextDouble(): ‱ receives the next token from scanner object which can be expressed as an double and stored in double type  nextLine(): ‱ receives the next line of the string
  • 14. ‱ package scanner; ‱ import java.util.Scanner; ‱ public class scannerDemo { ‱ void sum(int a, float b){ ‱ double result=a+b; ‱ System.out.println("the sum is = "+result); ‱ } ‱ public static void main(String[] args){ ‱ Scanner scanner=new Scanner(System.in); ‱ System.out.println("input integer value:"); ‱ int num1=scanner.nextInt(); ‱ System.out.println("input double value:"); ‱ float num2=scanner.nextFloat(); ‱ scannerDemo scannerDemo=new scannerDemo(); ‱ scannerDemo.sum(num1, num2); ‱ } ‱ }
  • 15. ‱ http://www.tutorialspoint.com/java/io/java_io_bufferedreader.htm ‱ http://www.slideshare.net/sonibabu/scanner-classes ‱ https://www.facebook.com/javatpoint ‱ http://www.javatpoint.com/cloud-computing-tutorial