]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.util/src/org/argeo/util/StreamUtils.java
Make CMS running without data area, and remove unnecessary dependencies.
[lgpl/argeo-commons.git] / org.argeo.util / src / org / argeo / util / StreamUtils.java
index 1cfa5b2206fe0c83ff044d6871277b9c4cdf92f0..30404f1e4edc195b9270488b1b0ed41eb7056187 100644 (file)
@@ -1,28 +1,15 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
 package org.argeo.util;
 
+import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.Reader;
 import java.io.Writer;
+import java.util.StringJoiner;
 
-/** Utilities to be used when APache COmmons IO is not available. */
-class StreamUtils {
+/** Stream utilities to be used when Apache Commons IO is not available. */
+public class StreamUtils {
        private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
 
        /*
@@ -30,8 +17,7 @@ class StreamUtils {
         */
 
        /** @return the number of bytes */
-       public static Long copy(InputStream in, OutputStream out)
-                       throws IOException {
+       public static Long copy(InputStream in, OutputStream out) throws IOException {
                Long count = 0l;
                byte[] buf = new byte[DEFAULT_BUFFER_SIZE];
                while (true) {
@@ -93,4 +79,12 @@ class StreamUtils {
                                //
                        }
        }
+
+       public static String toString(BufferedReader reader) throws IOException {
+               StringJoiner sn = new StringJoiner("\n");
+               String line = null;
+               while ((line = reader.readLine()) != null)
+                       sn.add(line);
+               return sn.toString();
+       }
 }