Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Throws IO Exception in method problem. (http://www.velocityreviews.com/forums/t642109-throws-io-exception-in-method-problem.html)

justineee 10-29-2008 02:04 PM

Throws IO Exception in method problem.
 
Hi Everyone,

I want this readfile method to be called in my other class but the
problem is the "throws IO Exception" code..
It says in the other class that "unreported exception
java.io.IOException; must be caught or declared to be thrown"

import java.util.*;
import java.io.*;


public class ReadFile
{
public void loadFile()
throws IOException
{
int nWords = 0;
FileReader f = new FileReader ("initlist.txt");
Scanner input = new Scanner ( f );
while (input.hasNextLine())
{
String line = input.nextLine();
System.out.println(line);
nWords++;
}
}
}

How will I fix this?? Thanks


Justine



All times are GMT. The time now is 03:06 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57