当前位置: 技术问答>java相关
巨简单的问题,不过我没找出来,请知道的来领分!!
来源: 互联网 发布时间:2015-06-05
本文导语: 请问如下程序为什么说有错误? 错误如下:分别在程序中注释的1,2处。 "Head.java": Error #: 360 : unreported exception: java.io.FileNotFoundException; must be caught or declared to be thrown at line 21, column 46 "Head.java": Er...
请问如下程序为什么说有错误?
错误如下:分别在程序中注释的1,2处。
"Head.java": Error #: 360 : unreported exception: java.io.FileNotFoundException; must be caught or declared to be thrown at line 21, column 46
"Head.java": Error #: 360 : unreported exception: java.io.IOException; must be caught or declared to be thrown at line 24, column 15
import java.io.*;
public class Head {
public void printLine10(String filename) {
File f=new File(filename);
if(!f.exists()) fail("No such file: "+filename);
if(f.isDirectory()) fail(filename+"is a directory! Not a file!");
BufferedReader in=new BufferedReader(new FileReader(f)); //1
String line;
for(int i=1;i
错误如下:分别在程序中注释的1,2处。
"Head.java": Error #: 360 : unreported exception: java.io.FileNotFoundException; must be caught or declared to be thrown at line 21, column 46
"Head.java": Error #: 360 : unreported exception: java.io.IOException; must be caught or declared to be thrown at line 24, column 15
import java.io.*;
public class Head {
public void printLine10(String filename) {
File f=new File(filename);
if(!f.exists()) fail("No such file: "+filename);
if(f.isDirectory()) fail(filename+"is a directory! Not a file!");
BufferedReader in=new BufferedReader(new FileReader(f)); //1
String line;
for(int i=1;i