This is an automated email from the ASF dual-hosted git repository. liujun pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/master by this push: new f4d97c5 enhance the java doc of dubbo-common module. (#5575) f4d97c5 is described below commit f4d97c5ae99f30999a5537758312fe1b03971e67 Author: withthewind <withthewind_git...@aliyun.com> AuthorDate: Sun Feb 9 13:20:11 2020 +0800 enhance the java doc of dubbo-common module. (#5575) --- .../org/apache/dubbo/common/utils/IOUtils.java | 40 +++++++++++++++------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/IOUtils.java b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/IOUtils.java index 095cd15..02ec00b 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/IOUtils.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/IOUtils.java @@ -33,6 +33,13 @@ import java.io.Writer; import java.util.ArrayList; import java.util.List; +/** + * Miscellaneous io utility methods. + * Mainly for internal use within the framework. + * + * @author william.liangf + * @since 2.0.7 + */ public class IOUtils { private static final int BUFFER_SIZE = 1024 * 8; public static final int EOF = -1; @@ -46,7 +53,7 @@ public class IOUtils { * @param is InputStream instance. * @param os OutputStream instance. * @return count. - * @throws IOException + * @throws IOException If an I/O error occurs */ public static long write(InputStream is, OutputStream os) throws IOException { return write(is, os, BUFFER_SIZE); @@ -59,14 +66,23 @@ public class IOUtils { * @param os OutputStream instance. * @param bufferSize buffer size. * @return count. - * @throws IOException + * @throws IOException If an I/O error occurs */ public static long write(InputStream is, OutputStream os, int bufferSize) throws IOException { byte[] buff = new byte[bufferSize]; return write(is, os, buff); } - public static long write (final InputStream input, final OutputStream output, final byte[] buffer) throws IOException { + /** + * write. + * + * @param input InputStream instance. + * @param output OutputStream instance. + * @param buffer buffer byte array + * @return count. + * @throws IOException If an I/O error occurs + */ + public static long write(final InputStream input, final OutputStream output, final byte[] buffer) throws IOException { long count = 0; int n; while (EOF != (n = input.read(buffer))) { @@ -81,7 +97,7 @@ public class IOUtils { * * @param reader Reader instance. * @return String. - * @throws IOException + * @throws IOException If an I/O error occurs */ public static String read(Reader reader) throws IOException { try (StringWriter writer = new StringWriter()) { @@ -95,7 +111,7 @@ public class IOUtils { * * @param writer Writer instance. * @param string String. - * @throws IOException + * @throws IOException If an I/O error occurs */ public static long write(Writer writer, String string) throws IOException { try (Reader reader = new StringReader(string)) { @@ -109,7 +125,7 @@ public class IOUtils { * @param reader Reader. * @param writer Writer. * @return count. - * @throws IOException + * @throws IOException If an I/O error occurs */ public static long write(Reader reader, Writer writer) throws IOException { return write(reader, writer, BUFFER_SIZE); @@ -122,7 +138,7 @@ public class IOUtils { * @param writer Writer. * @param bufferSize buffer size. * @return count. - * @throws IOException + * @throws IOException If an I/O error occurs */ public static long write(Reader reader, Writer writer, int bufferSize) throws IOException { int read; @@ -140,7 +156,7 @@ public class IOUtils { * * @param file file. * @return lines. - * @throws IOException + * @throws IOException If an I/O error occurs */ public static String[] readLines(File file) throws IOException { if (file == null || !file.exists() || !file.canRead()) { @@ -155,7 +171,7 @@ public class IOUtils { * * @param is input stream. * @return lines. - * @throws IOException + * @throws IOException If an I/O error occurs */ public static String[] readLines(InputStream is) throws IOException { List<String> lines = new ArrayList<String>(); @@ -173,7 +189,7 @@ public class IOUtils { * * @param os output stream. * @param lines lines. - * @throws IOException + * @throws IOException If an I/O error occurs */ public static void writeLines(OutputStream os, String[] lines) throws IOException { try (PrintWriter writer = new PrintWriter(new OutputStreamWriter(os))) { @@ -189,7 +205,7 @@ public class IOUtils { * * @param file file. * @param lines lines. - * @throws IOException + * @throws IOException If an I/O error occurs */ public static void writeLines(File file, String[] lines) throws IOException { if (file == null) { @@ -203,7 +219,7 @@ public class IOUtils { * * @param file file. * @param lines lines. - * @throws IOException + * @throws IOException If an I/O error occurs */ public static void appendLines(File file, String[] lines) throws IOException { if (file == null) {