Solved

java error

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

778 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