
-----------------------------------
SsJBebiGoku
Wed Oct 20, 2004 8:25 am

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:

public void fileRead()
	{
		try
		{
			FileReader fileIn = new FileReader("input.txt");
			BufferedReader stIn = new BufferedReader(fileIn);

-----------------------------------
Tony
Wed Oct 20, 2004 9:47 am


-----------------------------------
try the absolute path
"c:\folder\input.txt" or something

-----------------------------------
rizzix
Wed Oct 20, 2004 1:28 pm


-----------------------------------
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
Wed Oct 20, 2004 2:28 pm


-----------------------------------
You don't need the intermediate object, either.  :)

-----------------------------------
rizzix
Wed Oct 20, 2004 5:04 pm


-----------------------------------
You don't need the intermediate object, either.  :)

ehm... ? haha funny :lol:  this is java btw


i guess binary code was  a bit miss leading.. i should've said bytecode my mistake

-----------------------------------
wtd
Wed Oct 20, 2004 5:15 pm


-----------------------------------
You don't need the intermediate object, either.  :)

ehm... ? haha funny :lol:  this is java btw

I was talking about this:

FileReader fileIn = new FileReader("input.txt");
BufferedReader stIn = new BufferedReader(fileIn);

Which could just as easily be:

BufferedReader stIn = new BufferedReader(new FileReader("input.txt"));

-----------------------------------
rizzix
Wed Oct 20, 2004 5:20 pm


-----------------------------------
pfft and i thought object files.. my mistake.. again
