first version of 'Code Assist" template engine
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / corext / util / IOCloser.java
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/util/IOCloser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/util/IOCloser.java
new file mode 100644 (file)
index 0000000..6ed53f7
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2002 International Business Machines Corp. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v0.5 
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package net.sourceforge.phpdt.internal.corext.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+//import org.eclipse.jdt.internal.ui.JavaPlugin;
+
+public class IOCloser {
+       public static void perform(Reader reader, InputStream stream) {
+               try {
+                       rethrows(reader, stream);
+               } catch (IOException e) {
+                       PHPeclipsePlugin.log(e);
+               }
+       }
+       
+       public static void rethrows(Reader reader, InputStream stream) throws IOException {
+               if (reader != null) {
+                       reader.close();
+                       return;
+               }
+               if (stream != null) {
+                       stream.close();
+                       return;
+               }
+       }       
+}
+