Solved

java error

Posted on 2007-04-01
1
149 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
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…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

713 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