Re: Frustrated trying to Read File
"bH" <bherbst65@hotmail.com> wrote in news:1161198597.015168.180950
@b28g2000cwb.googlegroups.com:
Hi All,
I have this program below but it won't compile without errors.
The errors reported at this time are noted below the program.
Help is appreciated.
bH
import java.io.*;
public class ReadFile {
String strArry[] = new String[15];
public static void main (String args[])throws Exception{
//System.out.println("here");
ReadFile rFile = new ReadFile();
rFile.test();
} //main
public void test(){
try{
FileInputStream fis = new
FileInputStream("NameAgeWeightFile.txt");
BufferedReader bor = new BufferedReader(new
InputStreamReader(fis));
for(int i=0; i<15; i++){
strArry[i] = bor.readLine();
} //end of for
bor.close();
} //end of try
catch (Exception e) {
System.out.println("error getting data");
} //end of catch
for(int ic=0; ic<15; ic++){
System.out.println (strArry[ic]);
} //end of for
} //end of test
} //end of ReadFile
error list:
ReadFile.java, Line 16 : Class BufferedReader not found in type
declaration.
BufferedReader bor = new BufferedReader (new
InputStreamReader(fis));
^
ReadFile.java, Line 16 : Class BufferedReader not found in type
declaration.
BufferedReader bor = new BufferedReader (new
InputStreamReader(fis));
^
ReadFile.java, Line 19 : Class BufferedReader not found in void test().
strArry[i] = bor.readLine();
^
ReadFile.java, Line 19 : Class BufferedReader not found in void test().
strArry[i] = bor.close();
^
Compiled fine for me under JDK 1.5.0_08, using Eclipse 3.2.0.
Check your setup (environment, compiler, IDE, etc.).
When run, produced:
error getting data
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
Wll, what did you expect? I didn't have a file NameAgeWeightFile.txt
Good luck!
--
Ian Shef 805/F6 * These are my personal opinions
Raytheon Company * and not those of my employer.
PO Box 11337 *
Tucson, AZ 85734-1337 *