1616 */
1717package com .egzosn .pay .common .util ;
1818
19- import java .io .BufferedInputStream ;
20- import java .io .BufferedReader ;
21- import java .io .ByteArrayInputStream ;
22- import java .io .ByteArrayOutputStream ;
23- import java .io .CharArrayWriter ;
24- import java .io .Closeable ;
25- import java .io .EOFException ;
26- import java .io .IOException ;
27- import java .io .InputStream ;
28- import java .io .InputStreamReader ;
29- import java .io .OutputStream ;
30- import java .io .OutputStreamWriter ;
31- import java .io .PrintWriter ;
32- import java .io .Reader ;
33- import java .io .StringWriter ;
34- import java .io .UnsupportedEncodingException ;
35- import java .io .Writer ;
36- import java .net .HttpURLConnection ;
37- import java .net .ServerSocket ;
38- import java .net .Socket ;
39- import java .net .URI ;
40- import java .net .URL ;
41- import java .net .URLConnection ;
19+ import org .apache .commons .codec .Charsets ;
20+
21+ import java .io .*;
22+ import java .net .*;
4223import java .nio .channels .Selector ;
4324import java .nio .charset .Charset ;
4425import java .nio .charset .UnsupportedCharsetException ;
4526import java .util .ArrayList ;
4627import java .util .Collection ;
4728import java .util .List ;
4829
49- import org .apache .commons .codec .Charsets ;
50-
5130/**
5231 * General IO stream manipulation utilities.
5332 * <p>
8059 * Origin of code: Excalibur.
8160 *
8261 * @version $Id: IOUtils.java 1326636 2012-04-16 14:54:53Z ggregory $
83- *
8462 */
8563public class IOUtils {
8664 // NOTE: This class is focussed on InputStream, OutputStream, Reader and
@@ -283,8 +261,7 @@ public static void closeQuietly(Closeable closeable) {
283261 if (closeable != null ) {
284262 closeable .close ();
285263 }
286- }
287- catch (IOException ioe ) {
264+ } catch (IOException ioe ) {
288265 // ignore
289266 }
290267 }
@@ -316,8 +293,7 @@ public static void closeQuietly(Socket sock) {
316293 if (sock != null ) {
317294 try {
318295 sock .close ();
319- }
320- catch (IOException ioe ) {
296+ } catch (IOException ioe ) {
321297 // ignored
322298 }
323299 }
@@ -350,8 +326,7 @@ public static void closeQuietly(Selector selector) {
350326 if (selector != null ) {
351327 try {
352328 selector .close ();
353- }
354- catch (IOException ioe ) {
329+ } catch (IOException ioe ) {
355330 // ignored
356331 }
357332 }
@@ -384,8 +359,7 @@ public static void closeQuietly(ServerSocket sock) {
384359 if (sock != null ) {
385360 try {
386361 sock .close ();
387- }
388- catch (IOException ioe ) {
362+ } catch (IOException ioe ) {
389363 // ignored
390364 }
391365 }
@@ -409,7 +383,6 @@ public static void closeQuietly(ServerSocket sock) {
409383 *
410384 * @param input Stream to be fully buffered.
411385 * @return A fully buffered stream.
412- * @throws IOException if an I/O error occurs
413386 * @since 2.0
414387 */
415388 public static InputStream toBufferedInputStream (InputStream input ) {
@@ -612,8 +585,7 @@ public static byte[] toByteArray(URL url) throws IOException {
612585 URLConnection conn = url .openConnection ();
613586 try {
614587 return IOUtils .toByteArray (conn );
615- }
616- finally {
588+ } finally {
617589 close (conn );
618590 }
619591 }
@@ -631,8 +603,7 @@ public static byte[] toByteArray(URLConnection urlConn) throws IOException {
631603 InputStream inputStream = urlConn .getInputStream ();
632604 try {
633605 return IOUtils .toByteArray (inputStream );
634- }
635- finally {
606+ } finally {
636607 inputStream .close ();
637608 }
638609 }
@@ -864,8 +835,7 @@ public static String toString(URL url, Charset encoding) throws IOException {
864835 InputStream inputStream = url .openStream ();
865836 try {
866837 return toString (inputStream , encoding );
867- }
868- finally {
838+ } finally {
869839 inputStream .close ();
870840 }
871841 }
@@ -2252,7 +2222,7 @@ public static void skipFully(Reader input, long toSkip) throws IOException {
22522222 * @param input where to read input from
22532223 * @param buffer destination
22542224 * @param offset inital offset into buffer
2255- * @param length length to read, must be >= 0
2225+ * @param length length to read, must
22562226 * @return actual length read; may be less than requested if EOF was reached
22572227 * @throws IOException if a read error occurs
22582228 * @since 2.2
@@ -2298,7 +2268,7 @@ public static int read(Reader input, char[] buffer) throws IOException {
22982268 * @param input where to read input from
22992269 * @param buffer destination
23002270 * @param offset inital offset into buffer
2301- * @param length length to read, must be >= 0
2271+ * @param length length to read,
23022272 * @return actual length read; may be less than requested if EOF was reached
23032273 * @throws IOException if a read error occurs
23042274 * @since 2.2
@@ -2344,7 +2314,7 @@ public static int read(InputStream input, byte[] buffer) throws IOException {
23442314 * @param input where to read input from
23452315 * @param buffer destination
23462316 * @param offset inital offset into buffer
2347- * @param length length to read, must be >= 0
2317+ * @param length length to read, must
23482318 * @throws IOException if there is a problem reading the file
23492319 * @throws IllegalArgumentException if length is negative
23502320 * @throws EOFException if the number of characters read was incorrect
@@ -2383,7 +2353,7 @@ public static void readFully(Reader input, char[] buffer) throws IOException {
23832353 * @param input where to read input from
23842354 * @param buffer destination
23852355 * @param offset inital offset into buffer
2386- * @param length length to read, must be >= 0
2356+ * @param length length to read
23872357 * @throws IOException if there is a problem reading the file
23882358 * @throws IllegalArgumentException if length is negative
23892359 * @throws EOFException if the number of bytes read was incorrect
0 commit comments