By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,034 Members | 820 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,034 IT Pros & Developers. It's quick & easy.

readfing a text file using java error

P: n/a
i am having this error when trying to run:
Problem reading Threatalerts.txt
what could be my problem ?
where the file Threatalerts.txt should be stored?
this is my code

import java.io.*;
class ReadTextFile
{
public static void main ( String[] args )
{
String fileName ="Threatalerts.txt" ;
String line;

try
{
BufferedReader in = new BufferedReader(
new FileReader( fileName ) );
line = in.readLine();
while ( line != null ) // continue until end of file
{
System.out.println( line );
line = in.readLine();
}
in.close();
}
catch ( IOException iox )
{
System.out.println("Problem reading " + fileName );
}
}
}
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"GiiO" <gi******@hotmail.com> wrote in message
news:89**************************@posting.google.c om...
i am having this error when trying to run:
Problem reading Threatalerts.txt
what could be my problem ?
where the file Threatalerts.txt should be stored?


What is the actual IOException being thrown? It could be several things, but
most likely the file isn't found. Since you're catching the exception, you
won't see the real exception message unless you do e.printStacktrace(); in
the catch block.
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.