Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 NetBeans Reading Files
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
SsJBebiGoku




PostPosted: 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
Sponsor
sponsor
Tony




PostPosted: Wed Oct 20, 2004 9:47 am   Post subject: (No subject)

try the absolute path
"c:\folder\input.txt" or something
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
rizzix




PostPosted: 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




PostPosted: Wed Oct 20, 2004 2:28 pm   Post subject: (No subject)

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




PostPosted: Wed Oct 20, 2004 5:04 pm   Post subject: (No 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
wtd




PostPosted: Wed Oct 20, 2004 5:15 pm   Post subject: (No 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"));
rizzix




PostPosted: Wed Oct 20, 2004 5:20 pm   Post subject: (No subject)

pfft and i thought object files.. my mistake.. again
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: