Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

java error

Posted on 2007-04-01
1
Medium Priority
?
152 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 23

Accepted Solution

by:
Ajay-Singh earned 2000 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

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…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.
Suggested Courses

715 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