/** * Read some characters into the specified array. * * @param chars The character array to read into * @return The number of characters read or <code>-1</code> * if the end of file has been reached and * <code>throwEofException</code> is set to {@code false}. * @throws EOFException if the end of file is reached and * <code>throwEofException</code> is set to {@code true}. * @throws IOException if trying to read past the end of file. */ @Override public int read(final char[] chars) throws IOException { return read(chars, 0, chars.length); }
/** * Read a character. * * @return Either The character value returned by <code>processChar()</code> * or <code>-1</code> if the end of file has been reached and * <code>throwEofException</code> is set to {@code false}. * @throws EOFException if the end of file is reached and * <code>throwEofException</code> is set to {@code true}. * @throws IOException if trying to read past the end of file. */ @Override public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processChar(); }
/** * Read the specified number characters into an array. * * @param chars The character array to read into. * @param offset The offset to start reading characters into. * @param length The number of characters to read. * @return The number of characters read or <code>-1</code> * if the end of file has been reached and * <code>throwEofException</code> is set to {@code false}. * @throws EOFException if the end of file is reached and * <code>throwEofException</code> is set to {@code true}. * @throws IOException if trying to read past the end of file. */ @Override public int read(final char[] chars, final int offset, final int length) throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position += length; int returnLength = length; if (position > size) { returnLength = length - (int)(position - size); position = size; } processChars(chars, offset, returnLength); return returnLength; }
/** * Skip a specified number of characters. * * @param numberOfChars The number of characters to skip. * @return The number of characters skipped or <code>-1</code> * if the end of file has been reached and * <code>throwEofException</code> is set to {@code false}. * @throws EOFException if the end of file is reached and * <code>throwEofException</code> is set to {@code true}. * @throws IOException if trying to read past the end of file. */ @Override public long skip(final long numberOfChars) throws IOException { if (eof) { throw new IOException("Skip after end of file"); } if (position == size) { return doEndOfFile(); } position += numberOfChars; long returnLength = numberOfChars; if (position > size) { returnLength = numberOfChars - (position - size); position = size; } return returnLength; }
@Test public void testCopy_readerToWriter_IO84() throws Exception { final long size = (long)Integer.MAX_VALUE + (long)1; final Reader reader = new NullReader(size); final Writer writer = new NullWriter(); // Test copy() method assertEquals(-1, IOUtils.copy(reader, writer)); // reset the input reader.close(); // Test copyLarge() method assertEquals("copyLarge()", size, IOUtils.copyLarge(reader, writer)); }
/** * Skip a specified number of characters. * * @param numberOfChars The number of characters to skip. * @return The number of characters skipped or <code>-1</code> * if the end of file has been reached and * <code>throwEofException</code> is set to <code>false</code>. * @throws EOFException if the end of file is reached and * <code>throwEofException</code> is set to <code>true</code>. * @throws IOException if trying to read past the end of file. */ public long skip(long numberOfChars) throws IOException { if (eof) { throw new IOException("Skip after end of file"); } if (position == size) { return doEndOfFile(); } position += numberOfChars; long returnLength = numberOfChars; if (position > size) { returnLength = numberOfChars - (position - size); position = size; } return returnLength; }
ScriptThread() { stdout = new NullInputStream(); stdoutreader = new BufferedReader(new NullReader(100)); pipout = null; prout = null; }
/** * Read a character. * * @return Either The character value returned by <code>processChar()</code> * or <code>-1</code> if the end of file has been reached and * <code>throwEofException</code> is set to <code>false</code>. * @throws EOFException if the end of file is reached and * <code>throwEofException</code> is set to <code>true</code>. * @throws IOException if trying to read past the end of file. */ public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processChar(); }
/** * Read the specified number characters into an array. * * @param chars The character array to read into. * @param offset The offset to start reading characters into. * @param length The number of characters to read. * @return The number of characters read or <code>-1</code> * if the end of file has been reached and * <code>throwEofException</code> is set to <code>false</code>. * @throws EOFException if the end of file is reached and * <code>throwEofException</code> is set to <code>true</code>. * @throws IOException if trying to read past the end of file. */ public int read(char[] chars, int offset, int length) throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position += length; int returnLength = length; if (position > size) { returnLength = length - (int)(position - size); position = size; } processChars(chars, offset, returnLength); return returnLength; }
/** * Read some characters into the specified array. * * @param chars The character array to read into * @return The number of characters read or <code>-1</code> * if the end of file has been reached and * <code>throwEofException</code> is set to <code>false</code>. * @throws EOFException if the end of file is reached and * <code>throwEofException</code> is set to <code>true</code>. * @throws IOException if trying to read past the end of file. */ public int read(char[] chars) throws IOException { return read(chars, 0, chars.length); }
/** * Skip a specified number of characters. * * @param numberOfChars The number of characters to skip. * @return The number of characters skipped or <code>-1</code> * if the end of file has been reached and * <code>throwEofException</code> is set to <code>false</code>. * @throws EOFException if the end of file is reached and * <code>throwEofException</code> is set to <code>true</code>. * @throws IOException if trying to read past the end of file. */ public long skip(long numberOfChars) throws IOException { if (eof) { throw new IOException("Skip after end of file"); } if (position == size) { return doEndOfFile(); } position += numberOfChars; long returnLength = numberOfChars; if (position > size) { returnLength = numberOfChars - (position - size); position = size; } return returnLength; }
ScriptThread() { stdout = new NullInputStream(); stdoutreader = new BufferedReader(new NullReader(100)); pipout = null; prout = null; }
/** * Read a character. * * @return Either The character value returned by <code>processChar()</code> * or <code>-1</code> if the end of file has been reached and * <code>throwEofException</code> is set to <code>false</code>. * @throws EOFException if the end of file is reached and * <code>throwEofException</code> is set to <code>true</code>. * @throws IOException if trying to read past the end of file. */ public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processChar(); }
/** * Read the specified number characters into an array. * * @param chars The character array to read into. * @param offset The offset to start reading characters into. * @param length The number of characters to read. * @return The number of characters read or <code>-1</code> * if the end of file has been reached and * <code>throwEofException</code> is set to <code>false</code>. * @throws EOFException if the end of file is reached and * <code>throwEofException</code> is set to <code>true</code>. * @throws IOException if trying to read past the end of file. */ public int read(char[] chars, int offset, int length) throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position += length; int returnLength = length; if (position > size) { returnLength = length - (int)(position - size); position = size; } processChars(chars, offset, returnLength); return returnLength; }
@Override public int read(final char[] chars) throws IOException { return chars == null ? 0 : super.read(chars); } @Override
/** * Skip a specified number of characters. * * @param numberOfChars The number of characters to skip. * @return The number of characters skipped or <code>-1</code> * if the end of file has been reached and * <code>throwEofException</code> is set to {@code false}. * @throws EOFException if the end of file is reached and * <code>throwEofException</code> is set to {@code true}. * @throws IOException if trying to read past the end of file. */ @Override public long skip(final long numberOfChars) throws IOException { if (eof) { throw new IOException("Skip after end of file"); } if (position == size) { return doEndOfFile(); } position += numberOfChars; long returnLength = numberOfChars; if (position > size) { returnLength = numberOfChars - (position - size); position = size; } return returnLength; }
private LineNumberReader createReader() { IFileSpecification fileSpec = workspace.getFileSpecification(fileName); Reader reader; try { reader = fileSpec.createReader(); } catch (FileNotFoundException e) { reader = new NullReader(0); } return new LineNumberReader(reader); }
/** * Read a character. * * @return Either The character value returned by <code>processChar()</code> * or <code>-1</code> if the end of file has been reached and * <code>throwEofException</code> is set to {@code false}. * @throws EOFException if the end of file is reached and * <code>throwEofException</code> is set to {@code true}. * @throws IOException if trying to read past the end of file. */ @Override public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processChar(); }
/** * Read the specified number characters into an array. * * @param chars The character array to read into. * @param offset The offset to start reading characters into. * @param length The number of characters to read. * @return The number of characters read or <code>-1</code> * if the end of file has been reached and * <code>throwEofException</code> is set to {@code false}. * @throws EOFException if the end of file is reached and * <code>throwEofException</code> is set to {@code true}. * @throws IOException if trying to read past the end of file. */ @Override public int read(char[] chars, int offset, int length) throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position += length; int returnLength = length; if (position > size) { returnLength = length - (int)(position - size); position = size; } processChars(chars, offset, returnLength); return returnLength; }
@Override public int read(final CharBuffer target) throws IOException { return target == null ? 0 : super.read(target); } }