Solved

java error

Posted on 2007-04-01
1
144 Views
Last Modified: 2010-03-31
I have the follwing error:

com\psol\xbe2\Final.java:11: unreported exception java.io.FileNotFoundException;
 must be caught or declared to be thrown
        BufferedReader in = new BufferedReader(new FileReader("ex.txt"));
                                               ^
com\psol\xbe2\Final.java:14: unreported exception java.io.IOException; must be c
aught or declared to be thrown
        while ((str = in.readLine()) != null)
                                 ^
com\psol\xbe2\Final.java:18: unreported exception java.io.IOException; must be c
aught or declared to be thrown
        in.close();
                ^
3 errors

java file:
"
package com.psol.xbe2;

import java.io.*;

public class Final
   
{
    public static void main (String args[])
           {
       
        BufferedReader in = new BufferedReader(new FileReader("ex.txt"));
        String str;
        System.out.println("rrrrr");
        while ((str = in.readLine()) != null)
        {
             System.out.println(str);
        }
        in.close();
        }    
}
"
0
Comment
Question by:badour_ma
1 Comment
 
LVL 23

Accepted Solution

by:
Ajay-Singh earned 500 total points
ID: 18831742
> public static void main (String args[])


change to

public static void main (String args[]) throws IOException
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now