Computer Science Canada

NetBeans Reading Files

Author:  SsJBebiGoku [ 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);

Author:  Tony [ Wed Oct 20, 2004 9:47 am ]
Post subject: 

try the absolute path
"c:\folder\input.txt" or something

Author:  rizzix [ Wed Oct 20, 2004 1:28 pm ]
Post 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.

Author:  wtd [ Wed Oct 20, 2004 2:28 pm ]
Post subject: 

You don't need the intermediate object, either. Smile

Author:  rizzix [ Wed Oct 20, 2004 5:04 pm ]
Post subject: 

wtd wrote:
You don't need the intermediate object, either. Smile


ehm... ? haha funny Laughing this is java btw


i guess binary code was a bit miss leading.. i should've said bytecode my mistake

Author:  wtd [ Wed Oct 20, 2004 5:15 pm ]
Post subject: 

rizzix wrote:
wtd wrote:
You don't need the intermediate object, either. Smile


ehm... ? haha funny Laughing 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"));

Author:  rizzix [ Wed Oct 20, 2004 5:20 pm ]
Post subject: 

pfft and i thought object files.. my mistake.. again


: