I wanted to read data from multiple files simultaneously but I am getting NULL error.
Could anyone help in pointing out my error in the code.
I am not sure if I can make arrays of FileInputStream and DataInputStream the way I have done.
import java.io.*;
class Count1
{
static FileInputStream fstream[];
static DataInputStream in[];
static BufferedReader br[] ;
public static void main(String args[])
{
int count=0;
try{
// FileInputStream fstream[] = null ;
int i=0;
fstream[i++]=new FileInputStream("results1.txt"); // Null error in this line
fstream[i++]=new FileInputStream("results2.txt");
fstream[i++]=new FileInputStream("results3.txt");
fstream[i++]=new FileInputStream("results4.txt");
//DataInputStream in[] = null;
//BufferedReader br[] = null;
for(int j=0; j<i; j++)
{
in[j]=new DataInputStream(fstream[j]);
br[j] = new BufferedReader(new InputStreamReader(in[j]));
}
/*
Working on files
*/
for(int k=0; k<i; k++)
in[k].close();
}catch (Exception e){
System.out.println(e.getMessage());
}
}
}