/** Read the next line of text from the input stream. */ @Override public String readLine() throws IOException { return findString("\n"); }
/** * Read a string of arbitrary length, terminated by a null char. * * @return the smallest string such that the last character is a null byte * @throws IOException if a null-terminated string is not found * @see #findString(String...) */ public String readCString() throws IOException { return findString("\0"); }
/** * Reads a string ending with one of the given terminating substrings. * * @param terminators The strings for which to search. * * @return The string from the initial position through the end of the * terminating sequence, or through the end of the stream if no * terminating sequence is found. */ public String findString(String... terminators) throws IOException { return findString(true, DEFAULT_BLOCK_SIZE, terminators); }
/** Read the next line of text from the input stream. */ @Override public String readLine() throws IOException { return findString("\n"); }
/** Read a string of arbitrary length, terminated by a null char. */ public String readCString() throws IOException { return findString("\0"); }
/** * Reads a string ending with one of the given terminating substrings. * * @param terminators The strings for which to search. * * @return The string from the initial position through the end of the * terminating sequence, or through the end of the stream if no * terminating sequence is found. * @throws IOException If the maximum search length (512 MB) is exceeded. */ public String findString(String... terminators) throws IOException { return findString(true, DEFAULT_BLOCK_SIZE, terminators); }
/** * Reads a string ending with one of the given terminating * substrings, using the specified block size for buffering. * * @param blockSize The block size to use when reading bytes in chunks. * @param terminators The strings for which to search. * * @return The string from the initial position through the end of the * terminating sequence, or through the end of the stream if no * terminating sequence is found. */ public String findString(int blockSize, String... terminators) throws IOException { return findString(true, blockSize, terminators); }
/** * Reads a string ending with one of the given terminating * substrings, using the specified block size for buffering. * * @param blockSize The block size to use when reading bytes in chunks. * @param terminators The strings for which to search. * * @return The string from the initial position through the end of the * terminating sequence, or through the end of the stream if no * terminating sequence is found. * @throws IOException If the maximum search length (512 MB) is exceeded. */ public String findString(int blockSize, String... terminators) throws IOException { return findString(true, blockSize, terminators); }
/** * Reads or skips a string ending with * one of the given terminating substrings. * * @param saveString Whether to collect the string from the current file * pointer to the terminating bytes, and return it. If false, returns null. * @param terminators The strings for which to search. * * @throws IOException If saveString flag is set * and the maximum search length (512 MB) is exceeded. * * @return The string from the initial position through the end of the * terminating sequence, or through the end of the stream if no * terminating sequence is found, or null if saveString flag is unset. */ public String findString(boolean saveString, String... terminators) throws IOException { return findString(saveString, DEFAULT_BLOCK_SIZE, terminators); }
/** * Reads or skips a string ending with * one of the given terminating substrings. * * @param saveString Whether to collect the string from the current file * pointer to the terminating bytes, and return it. If false, returns null. * @param terminators The strings for which to search. * * @throws IOException If saveString flag is set * and the maximum search length (512 MB) is exceeded. * * @return The string from the initial position through the end of the * terminating sequence, or through the end of the stream if no * terminating sequence is found, or null if saveString flag is unset. * @throws IOException If saveString flag is set * and the maximum search length (512 MB) is exceeded. */ public String findString(boolean saveString, String... terminators) throws IOException { return findString(saveString, DEFAULT_BLOCK_SIZE, terminators); }
/** * Reads a string ending with one of the characters in the given string. * * @see #findString(String...) */ public String readString(String lastChars) throws IOException { if (lastChars.length() == 1) return findString(lastChars); String[] terminators = new String[lastChars.length()]; for (int i=0; i<terminators.length; i++) { terminators[i] = lastChars.substring(i, i + 1); } return findString(terminators); }
/** * Reads a string ending with one of the characters in the given string. * * @param lastChars string containing possible final characters for the returned string * @return the smallest string that ends in one of the characters in <code>lastChars</code> * @throws IOException If the maximum length (512 MB) is exceeded. * @see #findString(String...) */ public String readString(String lastChars) throws IOException { if (lastChars.length() == 1) return findString(lastChars); String[] terminators = new String[lastChars.length()]; for (int i=0; i<terminators.length; i++) { terminators[i] = lastChars.substring(i, i + 1); } return findString(terminators); }