I do have the try statement in my method and handle the exception within the method. I posted my code below.
import java.lang.Character;
import java.awt.*;
import java.io.*;
public class findlength extends Frame{
TextField filename=new TextField(20);
TextField longestline= new TextField(5);
TextField linenumber= new TextField(7);
String name;
Label reccount=new Label("THE LONGEST LINE IS "

;
Label linenum=new Label("FOUND AT LINE NUMBER "

;
public void doit() throws IOException
{
String file="init";
String line="init";
int largestrownumber=0;
int largestrecordlength=0;
int i=0;
File o =new File(name);
try{ BufferedReader reader1=new BufferedReader(new FileReader(o));
line=reader1.readLine();
while(line!=null)
{
i++;
if(line.length()>largestrecordlength)
{largestrecordlength=line.length();
largestrownumber=i;}
line=reader1.readLine();
}
//longestline.setText(largestrecordlength);
//linenumber.setText(largestrownumber);
// convert int to string and display.....
} catch (IOException e) {e.printStackTrace();}//end of try function
}//end of function doit
public findlength(){
super("FIND LENGTH APPLICATION"

;
setLayout(new BorderLayout());
initializebuttonbox();
initializecenter();
pack();
resize(300,300);
show();
}
public void initializebuttonbox()
{
Panel b=new Panel();
b.setLayout(new FlowLayout());
Button submit=new Button("SUBMIT"

;
b.add("South",submit);
Button reset=new Button("RESET"

;
b.add("South",reset);
Button close=new Button("CLOSE"

;
b.add("South",close);
add("South",b);
}
public void initializecenter()
{
Panel c=new Panel();
c.setLayout(new GridLayout(6,1));
c.add(new Label(" PLEASE ENTER THE FILE NAME BELOW "

);
c.add(filename);
c.add(reccount);
c.add(longestline);
c.add(linenum);
c.add(linenumber);
add("Center",c);
}
public boolean action(Event evt, Object arg) throws IOException
{
if(arg.equals("CLOSE"

)
{
dispose();
return true;
}
if(arg.equals("RESET"

)
{
filename.setText(""

;
longestline.setText(""

;
linenumber.setText(""

;
return true;
}
if(arg.equals("SUBMIT"

)
{
name=filename.getText();
doit();
return true;
}
return super.handleEvent(evt); }//end of event handler
public static void main(String args[])
{new findlength();
}//end of main function
}//end of class