[6064] in java-interest

home help back first fref pref prev next nref lref last post

Handling Exceptions - doubts ....

daemon@ATHENA.MIT.EDU (Dhaval M Shah)
Mon Mar 18 20:21:50 1996

Date:         Mon, 18 Mar 1996 19:19:01 +1100
Reply-To: Java Interest <JAVA-INTEREST@JAVASOFT.COM>
From: Dhaval M Shah <dms03@CS.UOW.EDU.AU>
To: Multiple recipients of list JAVA-INTEREST
              <JAVA-INTEREST@JAVASOFT.COM>

Hello Everybody,

I am not able to compile this code, because the compiler says....

-----
>filewindow.java:71: Exception java.io.IOException must be caught, or it must be declared in the throws clause of this method.
    fh.openfiles(infilename,indirectory);
                ^
>1 error
-----



While my program code is like this :

-----

class Filehandler
{
 public void openfiles(String infile, String indir)
        throws java.io.IOException
 {
    File newfile = new File(indir, infile);
    FileInputStream fis = new FileInputStream(newfile);
    FileOutputStream fos = new FileOutputStream(newfile);
    System.out.println("First Byte read is : " + fis.read());
 }
}

public class filewindow extends frame
{
  .....
  .....

  public boolean handleEvent(Event event)
  {
   ....
   ....

    Filehandler fh = new Filehandler();
    fh.openfiles(infilename,indirectory);
  }

  ....
}

-----------

Can somebody point out where I am going wrong - since I have decl.
java.io,IOException for void openfiles.

Thanks

Dhaval
--
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
   Dhaval M. Shah
   dms03@cs.uow.edu.au                 (Home) : +61 42 258519
   Dept. of Computer Science
   University of Wollongong             2/13 Catherine St., Gwynneville,
   NSW 2522     Australia               NSW 2500     Australia
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+

home help back first fref pref prev next nref lref last post