You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2012/05/28 22:48:50 UTC
svn commit: r1343388 -
/openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/IO.java
Author: dblevins
Date: Mon May 28 20:48:50 2012
New Revision: 1343388
URL: http://svn.apache.org/viewvc?rev=1343388&view=rev
Log:
added a few method overloads for copy and slurp
Modified:
openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/IO.java
Modified: openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/IO.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/IO.java?rev=1343388&r1=1343387&r2=1343388&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/IO.java (original)
+++ openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/IO.java Mon May 28 20:48:50 2012
@@ -133,25 +133,18 @@ public class IO {
}
}
- public static String slurp(String fileName) throws IOException {
- return slurp(new File(fileName));
+ public static String slurp(File file) throws IOException {
+ return slurp(read(file));
}
- public static String slurp(File file) throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- copy(file, out);
- return new String(out.toByteArray());
+
+ public static String slurp(URL url) throws IOException {
+ return slurp(url.openStream());
}
public static String slurp(InputStream in) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
copy(in, out);
- return new String(out.toByteArray(), "UTF-8");
- }
-
- public static String slurp(URL url) throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- copy(read(url), out);
return new String(out.toByteArray());
}
@@ -262,15 +255,6 @@ public class IO {
}
}
- public static void copy(byte[] from, File to) throws IOException {
- final OutputStream write = write(to);
- try {
- write.write(from);
- } finally {
- close(write);
- }
- }
-
public static void copy(InputStream from, File to, boolean append) throws IOException {
final OutputStream write = write(to, append);
try {
@@ -289,6 +273,14 @@ public class IO {
to.flush();
}
+ public static void copy(byte[] from, File to) throws IOException {
+ copy(new ByteArrayInputStream(from), to);
+ }
+
+ public static void copy(byte[] from, OutputStream to) throws IOException {
+ copy(new ByteArrayInputStream(from), to);
+ }
+
public static ZipOutputStream zip(File file) throws IOException {
final OutputStream write = write(file);
return new ZipOutputStream(write);