Monday, 19 October 2015

Reading from the file using FileInputStream in java

import java.io.*;
public class First {

public static void main(String[] args) throws IOException,FileNotFoundException {
// TODO Auto-generated method stub
FileInputStream fin = new FileInputStream("test.txt");
int ch;
while((ch=fin.read())!=-1){
System.out.println("the values in the file are " +(char)ch);

}
}

}


output:-
the values in the file are B
the values in the file are a
the values in the file are t
the values in the file are t
the values in the file are i
the values in the file are p
the values in the file are a
the values in the file are t
the values in the file are i
the values in the file are
the values in the file are s
the values in the file are a
the values in the file are i
the values in the file are
the values in the file are N
the values in the file are a
the values in the file are g
the values in the file are e
the values in the file are n
the values in the file are d
the values in the file are r
the values in the file are a
the values in the file are
the values in the file are B
the values in the file are h
the values in the file are a
the values in the file are v
the values in the file are a
the values in the file are n
the values in the file are i
the values in the file are
the values in the file are P
the values in the file are r
the values in the file are a
the values in the file are s
the values in the file are a
the values in the file are d
the values in the file are

the values in the file are

the values in the file are S
the values in the file are r
the values in the file are .
the values in the file are P
the values in the file are e
the values in the file are r
the values in the file are f
the values in the file are o
the values in the file are r
the values in the file are m
the values in the file are a
the values in the file are n
the values in the file are c
the values in the file are e
the values in the file are
the values in the file are E
the values in the file are n
the values in the file are g
the values in the file are i
the values in the file are n
the values in the file are e
the values in the file are e
the values in the file are r
the values in the file are

the values in the file are

No comments:

Post a Comment