/** * Read and return the entire contents of the supplied {@link InputStream}. This method always closes the stream when finished * reading. * * @param stream the streamed contents; may be null * @return the contents, or an empty string if the supplied stream is null * @throws IOException if there is an error reading the content */ public static String read( InputStream stream ) throws IOException { return IoUtil.read(stream); }
/** * Read and return the entire contents of the supplied {@link Reader}. This method always closes the reader when finished * reading. * * @param reader the reader of the contents; may be null * @return the contents, or an empty string if the supplied reader is null * @throws IOException if there is an error reading the content */ public static String read( Reader reader ) throws IOException { return IoUtil.read(reader); }
/** * Read and return the entire contents of the supplied {@link Reader}. This method always closes the reader when finished * reading. * * @param reader the reader of the contents; may be null * @return the contents, or an empty string if the supplied reader is null * @throws IOException if there is an error reading the content */ public static String read( Reader reader ) throws IOException { return IoUtil.read(reader); }
/** * Read and return the entire contents of the supplied {@link Reader}. This method always closes the reader when finished * reading. * * @param reader the reader of the contents; may be null * @return the contents, or an empty string if the supplied reader is null * @throws IOException if there is an error reading the content */ public static String read( Reader reader ) throws IOException { return IoUtil.read(reader); }
/** * Read and return the entire contents of the supplied {@link InputStream}. This method always closes the stream when finished * reading. * * @param stream the streamed contents; may be null * @return the contents, or an empty string if the supplied stream is null * @throws IOException if there is an error reading the content */ public static String read( InputStream stream ) throws IOException { return IoUtil.read(stream); }
/** * Read and return the entire contents of the supplied {@link InputStream}. This method always closes the stream when finished * reading. * * @param stream the streamed contents; may be null * @return the contents, or an empty string if the supplied stream is null * @throws IOException if there is an error reading the content */ public static String read( InputStream stream ) throws IOException { return IoUtil.read(stream); }
/** * Read and return the entire contents of the supplied {@link InputStream}. This method always closes the stream when finished * reading. * * @param stream the streamed contents; may be null * @return the contents, or an empty string if the supplied stream is null * @throws IOException if there is an error reading the content */ public static String read( InputStream stream ) throws IOException { return stream == null ? "" : read(new InputStreamReader(stream)); }
/** * Read and return the entire contents of the supplied {@link InputStream}. This method always closes the stream when finished * reading. * * @param stream the streamed contents; may be null * @return the contents, or an empty string if the supplied stream is null * @throws IOException if there is an error reading the content */ public static String read( InputStream stream ) throws IOException { return stream == null ? "" : read(new InputStreamReader(stream)); }
/** * Read and return the entire contents of the supplied {@link InputStream}. This method always closes the stream when finished * reading. * * @param stream the streamed contents; may be null * @return the contents, or an empty string if the supplied stream is null * @throws IOException if there is an error reading the content */ public static String read( InputStream stream ) throws IOException { return stream == null ? "" : read(new InputStreamReader(stream)); }
/** * Read and return the entire contents of the supplied {@link InputStream}. This method always closes the stream when finished * reading. * * @param stream the streamed contents; may be null * @param charset charset of the stream data; may not be null * @return the contents, or an empty string if the supplied stream is null * @throws IOException if there is an error reading the content */ public static String read( InputStream stream, String charset ) throws IOException { return stream == null ? "" : read(new InputStreamReader(stream, charset)); }
/** * Read and return the entire contents of the supplied {@link InputStream}. This method always closes the stream when finished * reading. * * @param stream the streamed contents; may be null * @param charset charset of the stream data; may not be null * @return the contents, or an empty string if the supplied stream is null * @throws IOException if there is an error reading the content */ public static String read( InputStream stream, String charset ) throws IOException { return stream == null ? "" : read(new InputStreamReader(stream, charset)); }
/** * Read and return the entire contents of the supplied {@link InputStream}. This method always closes the stream when finished * reading. * * @param stream the streamed contents; may be null * @param charset charset of the stream data; may not be null * @return the contents, or an empty string if the supplied stream is null * @throws IOException if there is an error reading the content */ public static String read( InputStream stream, String charset ) throws IOException { return stream == null ? "" : read(new InputStreamReader(stream, charset)); }
/** * Import the CND content from the supplied stream, placing the content into the importer's destination. * * @param file the file containing the CND content * @param problems where any problems encountered during import should be reported * @throws IOException if there is a problem reading from the supplied stream */ public void importFrom( File file, Problems problems ) throws IOException { importFrom(IoUtil.read(file), problems, file.getCanonicalPath()); }
/** * Import the CND content from the supplied stream, placing the content into the importer's destination. * * @param file the file containing the CND content * @param problems where any problems encountered during import should be reported * @throws IOException if there is a problem reading from the supplied stream */ public void importFrom( File file, Problems problems ) throws IOException { importFrom(IoUtil.read(file), problems, file.getCanonicalPath()); }
/** * {@inheritDoc} */ public String create( Reader reader, long approximateLength ) throws IoException { if (reader == null) return null; try { return IoUtil.read(reader); } catch (IOException err) { throw new IoException(GraphI18n.errorConvertingIo.text(Reader.class.getSimpleName(), String.class.getSimpleName()), err); } }
@Override @Before public void beforeEach() throws Exception { super.beforeEach(); // Load in the large value ... validLargeValues = new String[] {IoUtil.read(getClass().getClassLoader().getResourceAsStream("LoremIpsum1.txt")), IoUtil.read(getClass().getClassLoader().getResourceAsStream("LoremIpsum2.txt")), IoUtil.read(getClass().getClassLoader().getResourceAsStream("LoremIpsum3.txt"))}; }
@Override @Before public void beforeEach() throws Exception { super.beforeEach(); // Load in the large value ... validLargeValues = new String[] {IoUtil.read(getClass().getClassLoader().getResourceAsStream("LoremIpsum1.txt")), IoUtil.read(getClass().getClassLoader().getResourceAsStream("LoremIpsum2.txt")), IoUtil.read(getClass().getClassLoader().getResourceAsStream("LoremIpsum3.txt"))}; }
@Override @Before public void beforeEach() throws Exception { super.beforeEach(); // Load in the large value ... validLargeValues = new String[] {IoUtil.read(getClass().getClassLoader().getResourceAsStream("LoremIpsum1.txt")), IoUtil.read(getClass().getClassLoader().getResourceAsStream("LoremIpsum2.txt")), IoUtil.read(getClass().getClassLoader().getResourceAsStream("LoremIpsum3.txt"))}; }
private void loadExpectedFrom( String resourcePath ) throws IOException { InputStream stream = getClass().getClassLoader().getResourceAsStream(resourcePath); assertThat(stream, is(notNullValue())); try { addWords(expected, IoUtil.read(stream)); } finally { stream.close(); } }
@Test public void readShouldReturnEmptyStringForNullReader() throws Exception { assertThat(IoUtil.read((Reader)null), is("")); }