Posted: Wed Oct 20, 2004 8:25 am Post subject: NetBeans Reading Files
This works with the simpler IDEs, but when trying to do it from NetBeans, it said it could not find the file...
My file IS in my current filesystem, and it returns a "Cannot Find File" error..here's my code:
code:
public void fileRead()
{
try
{
FileReader fileIn = new FileReader("input.txt");
BufferedReader stIn = new BufferedReader(fileIn);
Sponsor Sponsor
Tony
Posted: Wed Oct 20, 2004 9:47 am Post subject: (No subject)
try the absolute path
"c:\folder\input.txt" or something
Posted: Wed Oct 20, 2004 1:28 pm Post subject: (No subject)
it will read the file only in the current directory.. i.e the directory in which the binary exectable (.jar or .class) is executed.. most IDE's separate the binary code from the source code.. just make sure the file ur trying to read is in the sam directory the .class files are in.
wtd
Posted: Wed Oct 20, 2004 2:28 pm Post subject: (No subject)
You don't need the intermediate object, either.
rizzix
Posted: Wed Oct 20, 2004 5:04 pm Post subject: (No subject)
wtd wrote:
You don't need the intermediate object, either.
ehm... ? haha funny this is java btw
i guess binary code was a bit miss leading.. i should've said bytecode my mistake
wtd
Posted: Wed Oct 20, 2004 5:15 pm Post subject: (No subject)
rizzix wrote:
wtd wrote:
You don't need the intermediate object, either.
ehm... ? haha funny this is java btw
I was talking about this:
code:
FileReader fileIn = new FileReader("input.txt");
BufferedReader stIn = new BufferedReader(fileIn);
Which could just as easily be:
code:
BufferedReader stIn = new BufferedReader(new FileReader("input.txt"));
rizzix
Posted: Wed Oct 20, 2004 5:20 pm Post subject: (No subject)
pfft and i thought object files.. my mistake.. again