Avalon
Diamond Member
I'm actually pretty good with Java, and had just completed my first programming assignment on my new computer. Only problem was, is that my file read was not properly reading files, so I just commented it out and just took the inputstream for my assignment at the time. But, now that I have some time to think about it, I went and wrote a simple file read program, and it's giving me the same problems. Perhaps I'm having coder's block, but I was hoping you guys could tell me what I was doing wrong. Here's the code:
import java.io.*;
class FileReadTest {
public static void main (String[] args) {
try {
String record = null;
FileReader fr = new FileReader("C:\\Homework\\prog.txt");
BufferedReader br = new BufferedReader(fr);
record = br.readLine();
System.out.println(record);
}//end try
catch(IOException e){
System.out.println(e);
}//end catch
}//end main
}//end FileReadTest
Where this program is compiled (successfully) in my C:\Homework folder along with the file "prog.txt". I can also do FileReader fr = new FileReader("prog.txt"); and get the same error upon runtime, which is:
"java.io.FileNotFoundException: C:\Homework\prog.txt (The system cannot find the file specified)"
My OS is Vista64 Ultimate, and I'm using the very latest Java SDK. Thoughts?
import java.io.*;
class FileReadTest {
public static void main (String[] args) {
try {
String record = null;
FileReader fr = new FileReader("C:\\Homework\\prog.txt");
BufferedReader br = new BufferedReader(fr);
record = br.readLine();
System.out.println(record);
}//end try
catch(IOException e){
System.out.println(e);
}//end catch
}//end main
}//end FileReadTest
Where this program is compiled (successfully) in my C:\Homework folder along with the file "prog.txt". I can also do FileReader fr = new FileReader("prog.txt"); and get the same error upon runtime, which is:
"java.io.FileNotFoundException: C:\Homework\prog.txt (The system cannot find the file specified)"
My OS is Vista64 Ultimate, and I'm using the very latest Java SDK. Thoughts?