Article View: borland.public.jbuilder.java.api
Article #2263Re: File locked after stream closed
From: Al Mal
Date: Mon, 16 Apr 2001 00:13
Date: Mon, 16 Apr 2001 00:13
30 lines
1847 bytes
1847 bytes
"Torsten Welches" <torsten.welches@who.cares.netcologne.de> wrote in message
news:3ad9de16_1@dnews...
> Al,
>
> the file should not be locked. Are you sure that the close() lines
actually
> execute? How do you handle the IOExceptions? If, say, the read or write
> operations throw an exception your close will never get called.
> It is better to ensure the close in a finally block. Something like this:
>
> isURLStream = uDownloader.openStream();
> try {
> ..
> } finally {
> osFileStream.close(); // closig file stream
> isURLStream.close(); // closing connection to the URL content
> }
>
> Torsten
If I try to do that compiler complains:
"MainFrame.java": Error #: 360 : unreported exception: java.io.IOException;
must be caught or declared to be thrown at line 131, column 25
"MainFrame.java": Error #: 360 : unreported exception: java.io.IOException;
must be caught or declared to be thrown at line 132, column 24
What am I missing?
Al
Technical Details
Message-ID:
<3ada38db$1_2@dnews>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!134.222.94.5!npeer.kpnqwest.net!EU.net!blackbush.xlink.net!newsfeed01.sul.t-online.de!t-online.de!dnewsReferences:
<3ad7c343$1_2@dnews> <3ad9de16_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,ea1112c189c5d22f X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2001-04-15 17:42:48 PST From: "Al Mal" <alex.im@nospam.usa.net> Newsgroups: borland.public.jbuilder.java.api References: <3ad7c343$1_2@dnews> <3ad9de16_1@dnews> Subject: Re: File locked after stream closed Date: Sun, 15 Apr 2001 20:13:28 -0400 Lines: 32 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2462.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2462.0000 NNTP-Posting-Host: 64.231.4.136 Message-ID: <3ada38db$1_2@dnews> X-Trace: dnews 987379931 64.231.4.136 (15 Apr 2001 17:12:11 -0700) Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!134.222.94.5!npeer.kpnqwest.net!EU.net!blackbush.xlink.net!newsfeed01.sul.t-online.de!t-online.de!dnews