Solved

java error

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 video teaches viewers about errors in exception handling.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

911 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

24 Experts available now in Live!

Get 1:1 Help Now