Improved "Open Include" and "Open Include List" for external workspaces
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / util / StreamUtil.java
1 package net.sourceforge.phpdt.internal.ui.util;
2
3 import java.io.IOException;
4 import java.io.InputStream;
5 import java.io.OutputStream;
6
7 /**
8  * @author khartlage
9  * */
10 public class StreamUtil {
11   public static void transferStreams(InputStream source, OutputStream destination) throws IOException {
12     try {
13       byte[] buffer = new byte[8192];
14       while (true) {
15         int bytesRead = source.read(buffer);
16         if (bytesRead == -1)
17           break;
18         destination.write(buffer, 0, bytesRead);
19       }
20     } finally {
21       try {
22         source.close();
23       } catch (IOException e) {
24       }
25       try {
26         destination.close();
27       } catch (IOException e) {
28       }
29     }
30   }
31 }