6ed53f700ebef7c62fa9b7d7e9e1e7fd754fb874
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / corext / util / IOCloser.java
1 /*******************************************************************************
2  * Copyright (c) 2002 International Business Machines Corp. and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v0.5 
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v05.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  ******************************************************************************/
11 package net.sourceforge.phpdt.internal.corext.util;
12
13 import java.io.IOException;
14 import java.io.InputStream;
15 import java.io.Reader;
16
17 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
18
19 //import org.eclipse.jdt.internal.ui.JavaPlugin;
20
21 public class IOCloser {
22         public static void perform(Reader reader, InputStream stream) {
23                 try {
24                         rethrows(reader, stream);
25                 } catch (IOException e) {
26                         PHPeclipsePlugin.log(e);
27                 }
28         }
29         
30         public static void rethrows(Reader reader, InputStream stream) throws IOException {
31                 if (reader != null) {
32                         reader.close();
33                         return;
34                 }
35                 if (stream != null) {
36                         stream.close();
37                         return;
38                 }
39         }       
40 }
41