bufferReader and InputStreamReader

bufferReader and InputStreamReader

bufferReader and InputStreamReader are used for what purpose?

View Answers

March 11, 2011 at 4:37 PM

BufferedReader

BufferedReader read text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines.

import  java.io.*;
class BufferedReaderExample{
    public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new FileReader("C:/Hello.txt"));
    String line="";
    while((line = in.readLine()) != null){
    System.out.println(line);
    }
    }
}

InputStreamReader:

InputStreamReader reads bytes and decodes them into characters using a specified charset.

import java.io.*;    
public class InputStreamReaderExample {
    public static void main(String args[]) throws Exception {
        File file = new File("C:/Hello.txt");
        InputStreamReader reader = new InputStreamReader(new FileInputStream(file));
        int data = reader.read();
        while(data != -1){
        char theChar = (char) data;
        System.out.print(theChar);
        data = reader.read();
        }
    }
}









Related Tutorials/Questions & Answers:
bufferReader and InputStreamReader
bufferReader and InputStreamReader   bufferReader and InputStreamReader are used for what purpose
Java IO InputStreamReader
Java IO InputStreamReader In this section we will discuss about the InputStreamReader in Java. java.io.InputStreamReader class takes input as a byte... a specified charset. InputStreamReader acts as a bridge between the byte reading
Advertisements
BufferReader Example
Code: import java.io.*; class BufferedRead { public static void main(String args[]) throws IOException { char c; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("\nEnter character
BufferReader example in Java
BufferedReader(new InputStreamReader(in)); String strLine; //Read File Line By Line
how to read file using InputStreamReader in java
how to read file using InputStreamReader in java  Hi, I want to learn to use the InputStreamReader class of Java and trying to read a text file with the class. how to read file using InputStreamReader in java? Thanks  
Factorial Program in Java
execution of the program. BufferReader is defined under the Java I/O package.... InputStreamReader reads the input from user and then keep it into a buffer. As Java reads...{ BufferedReader object = new BufferedReader( new InputStreamReader(System.in
Java char to string
is using Scanner class. In this section we have also used BufferReader to convert... In BufferReader example, we have used toString() method, which converts.... BufferReader then reads the input from System.in and splits
How to Read file line by line in Java program
FileReader or InputStreamReader. The Reader buffers the input from a specific file... Example of Read file line by line using BufferReader: package ReadFile; import...); BufferedReader br = new BufferedReader(new InputStreamReader(inputStream
Java read text file
); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String
Calculator program in Java
time. InputStreamReader reads the input from System.in and then keep... reader = new BufferedReader(new InputStreamReader( System.in)); double x, y
Some error find whats the problem
Replace { public void main()throwsIoException { InputStreamReader = new InputStreamReader(System.in); BufferReader br=new BufferReader(z); System.out.println... { InputStreamReader z= new InputStreamReader(System.in); BufferedReader
Check even or odd number.
InputStreamReader(System.in)); String data = br.readLine(); num..."); } } } Description: num is variable which hold the inputted number. BufferReader
Calculate factorial of a number.
BufferedReader(new InputStreamReader(System.in)); String data = (String...)(n-3)?.1. BufferReader () is used for user input.BufferReader
Quries
Quries  a JAVA program to create an array of size 10 (Integer Values) by taking input from BufferReader and find out the average value of array elements from that array
java program
java program  write a java program to create an array of size 10 by taking input from bufferreader and find out the average of array elements from that array
java program
java program  write a java program to create an array of size 10 by taking input from bufferreader and find out the average of array elements from that array
java program
java program  write a java program to create an array of size 10 by taking input from bufferreader and find out the average of array elements from that array
Convert Text to Binary
the input from the keyboard we have used BufferReader() method in which we have passed an object of it which is InputStreamReader() as must be knowing...;=    new BufferedReader(new InputStreamReader(System.in
Convert Text to Binary
from the keyboard we have used BufferReader() method in which we have passed an object of it which is InputStreamReader() as must be knowing. Then we have...;BufferedReader(new InputStreamReader(System.in));   do {  
What is the use of BufferedReader in Java program?
the file/input stream (source stream). With help of InputStreamReader you can read the data into character stream. The InputStreamReader class reads the bytes from stream and then decode into characters. The InputStreamReader class uses
orderbill
orderbill  write a java code to take order of number of chocolates(bar,powder,giftbox) (use arraylistand use bufferreader to take input). Also consider exceptional cases like entering integer in name use try,catch ,throw to deal
please give me an idea to develop a program for this question?
please give me an idea to develop a program for this question?  How to enter a text or number from keyboard without using InputStreamReader method in java
Input and Output problems - Java Beginners
InputStreamReader and FileReader? 2) what is buffer?   Hi friend, InputStreamReader: An InputStreamReader is a bridge from byte streams to character.... When you create an InputStreamReader, you specify an InputStream from which
Java file encoding
. In the given example, we have used InputStreamReader class that wraps the input... { File in = new File("C:/file.txt"); InputStreamReader r = new InputStreamReader(new FileInputStream(in)); System.out.println(r.getEncoding
restrictedproductedui
{ InputStreamReader inStream = new InputStreamReader( System.in... { InputStreamReader inStream = new InputStreamReader( System.in
help please!!! T_T
InputName static InputStreamReader reader= new InputStreamReader(system.in... it. import java.io.*; class InputName{ static InputStreamReader reader = new InputStreamReader(System.in); static BufferedReader input = new
File Reader example in JRuby
" fileReader = FileReader.new "JRubyFile.txt" bufferReader.... bufferReader = BufferedReader.new fileReader str = bufferReader.readLine
possible loss of precision error
void main(String[] args) { InputStreamReader input = new InputStreamReader
java help - Java Beginners
void main(String[] args) { try { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader bufReader = new
about predefine classes.....
object = new BufferedReader( new InputStreamReader(System.in)); here what is the work of BufferedReader class and InputStreamReader...... pls tell
Buffered Reader.. - Java Beginners
BufferedReader(new InputStreamReader(System.in)); CAN u Please Explain the (Every Word) Above Statement in Detail.... BufferedReader => InputStreamReader..."); BufferedReader item = new BufferedReader(new InputStreamReader(System.in
How To Read File In Java with BufferedReader
); //Instantiate the BufferedReader Class BufferedReader bufferReader = new
Java char to string
BufferReader to read the input) Scanner splits the input into substrings consisting
Java Error - Java Beginners
[]) { char ch; InputStreamReader reader =new InputStreamReader...); //System.out.println("Enter characters, 'q' to quit."); try...[]) { InputStreamReader reader =new InputStreamReader (System.in
hello sir, please give me answer - Java Beginners
{public static void main(String arg[]) throws IOException { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr... to the constructor for InputStreamReader class. InputStreamReader' object is used as a parameter
JSP - Java Server Faces Questions
= in.getFileChannel().lock(); try { Reader reader = new InputStreamReader
i am unable to identify the error in my code
i am unable to identify the error in my code  class Program { public static void main(String[] args) { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("enter
i am unable to identify the error in my code
i am unable to identify the error in my code  class Program { public static void main(String[] args) { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("enter
need to fix errors please help
fix? import java.io.*; class InputName static InputStreamReader reader = new InputStreamReader(system.in); static BufferedReader input = new BufferedReader... InputStreamReader reader = new InputStreamReader(System.in); static
.bad file
.bad file  hi how can end this while dose not terminated Runtime r = Runtime.getRuntime(); Process p = r.exec("Run.bat"); BufferedReader reader = new BufferedReader(new InputStreamReader(new
.bat file
.bat file  hi how can end this while dose not terminated Runtime r = Runtime.getRuntime(); Process p = r.exec("Run.bat"); BufferedReader reader = new BufferedReader(new InputStreamReader(new
swapping - Java Interview Questions
main(String s[]) throws IOException { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader bufReader = new BufferedReader(isr
fibonacci series
fibonacci series  Program to print the first n fibonacci numbers using function.the program must use InputStreamReader and BufferedReader.  ... InputStreamReader(System.in)); System.out.print("Enter value of n: "); String st
Java Coding - Java Beginners
double getUPSShipping() throws IOException { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader bufReader = new BufferedReader(isr... double getFedExShipping() throws IOException { InputStreamReader isr
Java Code - Java Beginners
; InputStreamReader isr = new InputStreamReader(System.in
strings - Development process
= ""; InputStreamReader input = new InputStreamReader(System.in
programing - IoC
) throws Exception { String string = ""; InputStreamReader input = new InputStreamReader(System.in); BufferedReader reader = new BufferedReader(input
java - Java Beginners
InputStreamReader(System.in)); System.out.println("enter a char"); char ch=br.read... BufferedReader (new InputStreamReader(System.in)); System.out.println("enter a char
please explain this prog
{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in... InputStreamReader(System.in) allows the user to input string on the console. The method
code problem - Java Beginners
{ public static void main(String args[]) { try{ InputStreamReader input = new InputStreamReader(System.in); BufferedReader reader = new BufferedReader...(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String

Ads