Author: adietish
Date: 2011-05-31 09:51:38 -0400 (Tue, 31 May 2011)
New Revision: 31679
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/internal/FileUtils.java
Log:
[JBIDE-9023] fixed CoreException
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/internal/FileUtils.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/internal/FileUtils.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/internal/FileUtils.java 2011-05-31
13:51:38 UTC (rev 31679)
@@ -0,0 +1,44 @@
+package org.jboss.ide.eclipse.as.core.util.internal;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * Various util methods that allow to read and write to files.
+ *
+ * @author André Dietisheim
+ *
+ */
+public class FileUtils {
+
+ private static final int BUFFER = 65536;
+ private static byte[] buffer = new byte[BUFFER];
+
+ public static void writeTo(InputStream in, String fileName) throws IOException {
+ writeTo(in, new File(fileName));
+ }
+
+ public static void writeTo(InputStream in, File file) throws IOException {
+ OutputStream out = null;
+ try {
+ out = new BufferedOutputStream(new FileOutputStream(file));
+ writeTo(in, out);
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+
+ public static void writeTo(InputStream in, OutputStream out) throws IOException {
+ int avail = in.read(buffer);
+ while (avail > 0) {
+ out.write(buffer, 0, avail);
+ avail = in.read(buffer);
+ }
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/internal/FileUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Show replies by date