1) FileReader fop = new FileReader(f); // file or string
int n =0;
while ((n=fop.read())!=-1) // read a single character from file
System.out.print((char )n);
in above code we can use read(byte[]) too .
in that case it will read the data from file and populate in a defined byte array that can be printed / used later in next example done like that .
2) FileInputStream fis = new FileInputStream(f); // file or string
byte b[] = new byte[1048];
System.out.println(fis.read(b));
3) InputStream can be piped to InputStreamReader
InputStreamReader reader = new InputStreamReader(fis); // inputstream
4) Any reader instance can be piped to BufferedReader .
BufferedReader bufferedReader = new BufferedReader(fop); // Reader instance is required
BufferedReader bufferedReader = new BufferedReader(reader);// allowed instance of reader
we can readLine from BufferedReader.
int n =0;
while ((n=fop.read())!=-1) // read a single character from file
System.out.print((char )n);
in above code we can use read(byte[]) too .
in that case it will read the data from file and populate in a defined byte array that can be printed / used later in next example done like that .
2) FileInputStream fis = new FileInputStream(f); // file or string
byte b[] = new byte[1048];
System.out.println(fis.read(b));
3) InputStream can be piped to InputStreamReader
InputStreamReader reader = new InputStreamReader(fis); // inputstream
4) Any reader instance can be piped to BufferedReader .
BufferedReader bufferedReader = new BufferedReader(fop); // Reader instance is required
BufferedReader bufferedReader = new BufferedReader(reader);// allowed instance of reader
we can readLine from BufferedReader.