Hi Deployed the following code in eclipse
//import cs1.Keyboard;
import java.util.*;
import java.io.*;
public class Parser
{
public static void main (String[] args) throws IOException
{
String [][] addyArray = new String[50][4];
for (int j=0; j<50; j++)
{
for (int k=0; k<4; k++)
{
addyArray[j][k] = "\n";
}
}
FileReader inFile = new FileReader ("sample.txt");
BufferedReader in = new BufferedReader (inFile);
String line = "";
int i = 0, a = 0;
while(in.ready())
{
line = in.readLine();
while (line != null && line != "\n")
{
addyArray[i][a] = line;
line = in.readLine();
a++;
if (line == null) line = "\n";
}
i++;
a = 0;
}
for(int j=0; j<3; j++)
{
for(int k=0;k<4;k++)
{
System.out.println((j+1) + "-" + (k+1) + " " + addyArray[j] [k]);
}
}
}
}
I am getting the following error at this line FileReader inFile = new FileReader ("sample.txt");
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileReader.<init>(Unknown Source)
at Parser.main(Parser.java:19)
I placed sample.txt file in the same package folder where the above source code file was placed. I am not sure why I am getting this error. Can you please help me out. Thank you