General IO stream manipulation utilities. This class provides static utility methods for input/output operations. closeQuietly - these methods close a stream ignoring nulls and exceptions toXxx/read - these methods read data from a stream write - these methods write data to a st
| 98 | * @version $Id$ |
| 99 | */ |
| 100 | public class IOUtils { |
| 101 | // NOTE: This class is focused on InputStream, OutputStream, Reader and |
| 102 | // Writer. Each method should take at least one of these as a parameter, |
| 103 | // or return one of them. |
| 104 | |
| 105 | /** |
| 106 | * Represents the end-of-file (or stream). |
| 107 | * @since 2.5 (made public) |
| 108 | */ |
| 109 | public static final int EOF = -1; |
| 110 | |
| 111 | /** |
| 112 | * The Unix directory separator character. |
| 113 | */ |
| 114 | public static final char DIR_SEPARATOR_UNIX = '/'; |
| 115 | /** |
| 116 | * The Windows directory separator character. |
| 117 | */ |
| 118 | public static final char DIR_SEPARATOR_WINDOWS = '\\'; |
| 119 | /** |
| 120 | * The system directory separator character. |
| 121 | */ |
| 122 | public static final char DIR_SEPARATOR = File.separatorChar; |
| 123 | /** |
| 124 | * The Unix line separator string. |
| 125 | */ |
| 126 | public static final String LINE_SEPARATOR_UNIX = "\n"; |
| 127 | /** |
| 128 | * The Windows line separator string. |
| 129 | */ |
| 130 | public static final String LINE_SEPARATOR_WINDOWS = "\r\n"; |
| 131 | /** |
| 132 | * The system line separator string. |
| 133 | */ |
| 134 | public static final String LINE_SEPARATOR; |
| 135 | |
| 136 | static { |
| 137 | // avoid security issues |
| 138 | final StringBuilderWriter buf = new StringBuilderWriter(4); |
| 139 | final PrintWriter out = new PrintWriter(buf); |
| 140 | out.println(); |
| 141 | LINE_SEPARATOR = buf.toString(); |
| 142 | out.close(); |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * The default buffer size ({@value}) to use for |
| 147 | * {@link #copyLarge(InputStream, OutputStream)} |
| 148 | * and |
| 149 | * {@link #copyLarge(Reader, Writer)} |
| 150 | */ |
| 151 | private static final int DEFAULT_BUFFER_SIZE = 1024 * 4; |
| 152 | |
| 153 | /** |
| 154 | * The default buffer size to use for the skip() methods. |
| 155 | */ |
| 156 | private static final int SKIP_BUFFER_SIZE = 2048; |
| 157 |