KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > corext > util > IOCloser


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.corext.util;
12
13 import java.io.IOException JavaDoc;
14 import java.io.InputStream JavaDoc;
15 import java.io.Reader JavaDoc;
16
17 import org.eclipse.jdt.internal.ui.JavaPlugin;
18
19 public class IOCloser {
20     public static void perform(Reader JavaDoc reader, InputStream JavaDoc stream) {
21         try {
22             rethrows(reader, stream);
23         } catch (IOException JavaDoc e) {
24             JavaPlugin.log(e);
25         }
26     }
27     
28     public static void rethrows(Reader JavaDoc reader, InputStream JavaDoc stream) throws IOException JavaDoc {
29         if (reader != null) {
30             reader.close();
31             return;
32         }
33         if (stream != null) {
34             stream.close();
35             return;
36         }
37     }
38 }
39
40
Popular Tags