Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

reading a txt file in netbeans

807588May 19 2009 — edited May 19 2009
Hi, i am trying to read a txt file containing dictionary words. I searched online and did find some code to help do this, when i did compile and run it using jgrasp, it worked perfectly, but when i did copy d code and put it in my project in netbeans, it throws the filenotfound exception. Please any ideas on how to do this on netbeans??

code:

import java.io.BufferedReader;
import java.io.FileReader;
public class Dic
{
public static void main(String args[])
{

try
{

//FileReader fread=null;
BufferedReader bread = new BufferedReader(new FileReader("dic.txt"));

String line;
while((line=bread.readLine())!=null)
{
String[] tkn =line.split(",");
for(int i=0; i<tkn.length;i++)
{
String s=tkn;
System.out.println(s);

}
}

}

catch(Exception e)
{
System.out.println("Exception: " + e);
}

}

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 16 2009
Added on May 19 2009
6 comments
885 views