Article View: borland.public.jbuilder.java.api
Article #2269Re: File locked after stream closed
From: Torsten Welches
Date: Mon, 16 Apr 2001 10:29
Date: Mon, 16 Apr 2001 10:29
52 lines
2201 bytes
2201 bytes
Al,
close throws IOExceptions as well, so would need yet another try..catch
block:
try {
...
} finally {
try {
osFileStream.close();
...
} catch (IOException closeException) {
closeException.printStackTrace(); //or whatever
}
}
Torsten
Al Mal schrieb in Nachricht <3ada38db$1_2@dnews>...
>"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:
<3adac8e4_1@dnews>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!newsfeed1.uni2.dk!newssuck.uni2.dk!dnewsReferences:
<3ad7c343$1_2@dnews> <3ad9de16_1@dnews> <3ada38db$1_2@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-16 03:32:17 PST From: "Torsten Welches" <torsten.welches@who.cares.netcologne.de> Newsgroups: borland.public.jbuilder.java.api References: <3ad7c343$1_2@dnews> <3ad9de16_1@dnews> <3ada38db$1_2@dnews> Subject: Re: File locked after stream closed Date: Mon, 16 Apr 2001 12:29:19 +0200 Lines: 54 X-Newsreader: Microsoft Outlook Express 4.72.3110.5 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 NNTP-Posting-Host: 194.8.205.160 Message-ID: <3adac8e4_1@dnews> X-Trace: dnews 987416804 194.8.205.160 (16 Apr 2001 03:26:44 -0700) Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews