Reads the contents of this source as a string. @throws IOException if an I/O error occurs while reading from this source
()
| 288 | * @throws IOException if an I/O error occurs while reading from this source |
| 289 | */ |
| 290 | public String read() throws IOException { |
| 291 | Closer closer = Closer.create(); |
| 292 | try { |
| 293 | Reader reader = closer.register(openStream()); |
| 294 | return CharStreams.toString(reader); |
| 295 | } catch (Throwable e) { |
| 296 | throw closer.rethrow(e); |
| 297 | } finally { |
| 298 | closer.close(); |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | /** |
| 303 | * Reads the first line of this source as a string. Returns {@code null} if this source is empty. |