/** * Safe read fully - do not return a null for an empty reader. * @param reader the input to read from. * @return the string. * @throws IOException if unable to read from reader. * @since Ant 1.7.1 */ public static String safeReadFully(Reader reader) throws IOException { String ret = readFully(reader); return ret == null ? "" : ret; }
/** * Get the complete input as a string * @param in the reader object * @return the complete input * @throws IOException if error reading */ @Override public String getToken(Reader in) throws IOException { return FileUtils.readFully(in); }
/** * Reads to the end of the stream, returning the contents as a String. * * @return the remaining contents of the reader, as a String * * @exception IOException if the underlying reader throws one during * reading */ protected final String readFully() throws IOException { return FileUtils.readFully(in, BUFFER_SIZE); } }
/** * Read data from the reader and return the * contents as a string. * @param rdr the reader object * @return the contents of the file as a string * @exception IOException if an error occurs */ public String readFully(Reader rdr) throws IOException { return FileUtils.readFully(rdr, bufferSize); }
/** * Read from reader till EOF. * @param rdr the reader from which to read. * @return the contents read out of the given reader. * * @throws IOException if the contents could not be read out from the * reader. */ public static String readFully(Reader rdr) throws IOException { return readFully(rdr, BUF_SIZE); }
/** * Computes a 'hashvalue' for a file content. * It reads the content of a file, convert that to String and use the * String.hashCode() method. * @param file The file for which the value should be computed * @return the hashvalue or <i>null</i> if the file couldn't be read */ // Because the content is only read the file will not be damaged. I tested // with JPG, ZIP and PDF as binary files. public String getValue(File file) { Reader r = null; try { if (!file.canRead()) { return null; } r = new FileReader(file); int hash = FileUtils.readFully(r).hashCode(); return Integer.toString(hash); } catch (Exception e) { return null; } finally { FileUtils.close(r); } }
fixData = fixLineFeeds(FileUtils .readFully(new InputStreamReader(in, "US-ASCII"))) .trim(); } finally {
BufferedWriter bw = new BufferedWriter(writer); String buf = fileUtils.readFully(br); if (buf == null) { buf = "";