c985574cab5c7615fef0ba7bfcf506fc8da63231
[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 net.sourceforge.phpdt.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)
31                         throws IOException {
32                 if (reader != null) {
33                         reader.close();
34                         return;
35                 }
36                 if (stream != null) {
37                         stream.close();
38                         return;
39                 }
40         }
41 }