Reads the contents of this source as a string. @throws IOException if an I/O error occurs in the process of reading from this source
()
| 229 | * @throws IOException if an I/O error occurs in the process of reading from this source |
| 230 | */ |
| 231 | public String read() throws IOException { |
| 232 | Closer closer = Closer.create(); |
| 233 | try { |
| 234 | Reader reader = closer.register(openStream()); |
| 235 | return CharStreams.toString(reader); |
| 236 | } catch (Throwable e) { |
| 237 | throw closer.rethrow(e); |
| 238 | } finally { |
| 239 | closer.close(); |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | /** |
| 244 | * Reads the first link of this source as a string. Returns {@code null} if this source is empty. |