Article View: borland.public.jbuilder.java.language
Article #16879Re: what about IOExceptions
From: Richard Wilkman
Date: Tue, 12 Jan 1999 00:00
Date: Tue, 12 Jan 1999 00:00
53 lines
2068 bytes
2068 bytes
Marcel:
You have to catch IOException as well as EOFException. Add another
catch block.
-Rich
Marcel Hell wrote:
>
> Hi, I try to start a method which uses readByte.
> The code of the method goes here:
>
> public static void kodiere(String sourcefile, String destinationfile) throws
> IOException {
>
> DataInput sourcefile = new DataInputStream(new
> FileInputStream(sourcefile));
> DataOutput destination = new DataOutputStream(new
> FileOutputStream(destinationfile));
> try {
> while(true){
> byte b = (byte) source.readByte(); // Read a byte from the source
> b = (byte) ((b+3)%256);
> destination.writeByte(b);}}
>
> catch (EOFException e) // End of the source file.
> {System.out.println("All right! Coding finished.");
> }
>
> when I have a statement like this:
> kodiere(sourcefile,destinationfile);
> ... I get an Error message "unreported Exception:java.io.IOException; must
> be caught or declared to be thrown"
>
> Now what is my mistake, what do I have to add??
>
> Thanx for help
> Marcel
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Rich Wilkman
Senior Quality Assurance Engineer
Borland JBuilder Team
If you see something that looks like an opinion up there,
it's mine and mine alone.
Mail sent to me from the newsgroups won't bounce but will
be ignored. If I have time, I'll respond, but you have
a better chance if you confine your posts to the newsgroups
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Technical Details
Message-ID:
<369B73E6.7B5F7992@inprise.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<77f85u$p8f9@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,c9d8c3f7cf0306c6 X-Google-Attributes: gidf74b3,public From: Richard Wilkman <rwilkman@inprise.com> Subject: Re: what about IOExceptions Date: 1999/01/12 Message-ID: <369B73E6.7B5F7992@inprise.com> X-Deja-AN: 431703267 Content-Transfer-Encoding: 7bit References: <77f85u$p8f9@forums.borland.com> Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language