/** * Indicates whether this reader is ready to be read without blocking. * * @return {@code true} if this reader will not block when {@code read} is * called, {@code false} if unknown or blocking will occur. * @throws IOException * if this reader is closed or some other I/O error occurs. * @see #read() * @see #read(char[], int, int) * @see #readLine() */ @Override public boolean ready() throws IOException { synchronized (lock) { checkNotClosed(); return ((end - pos) > 0) || in.ready(); } }
/** * Resets this reader's position to the last {@code mark()} location. * Invocations of {@code read()} and {@code skip()} will occur from this new * location. * * @throws IOException * if this reader is closed or no mark has been set. * @see #mark(int) * @see #markSupported() */ @Override public void reset() throws IOException { synchronized (lock) { checkNotClosed(); if (mark == -1) { throw new IOException("Invalid mark"); } this.pos = mark; this.lastWasCR = this.markedLastWasCR; } }
/** * Sets a mark position in this reader. The parameter {@code markLimit} * indicates how many characters can be read before the mark is invalidated. * Calling {@code reset()} will reposition the reader back to the marked * position if {@code markLimit} has not been surpassed. * * @param markLimit * the number of characters that can be read before the mark is * invalidated. * @throws IllegalArgumentException * if {@code markLimit < 0}. * @throws IOException * if an error occurs while setting a mark in this reader. * @see #markSupported() * @see #reset() */ @Override public void mark(int markLimit) throws IOException { if (markLimit < 0) { throw new IllegalArgumentException("markLimit < 0:" + markLimit); } synchronized (lock) { checkNotClosed(); this.markLimit = markLimit; this.mark = pos; this.markedLastWasCR = lastWasCR; } }
checkNotClosed(); if (end - pos >= charCount) { pos += charCount;
/** * Reads a single character from this reader and returns it with the two * higher-order bytes set to 0. If possible, BufferedReader returns a * character from the buffer. If there are no characters available in the * buffer, it fills the buffer and then returns a character. It returns -1 * if there are no more characters in the source reader. * * @return the character read or -1 if the end of the source reader has been * reached. * @throws IOException * if this reader is closed or some other I/O error occurs. */ @Override public int read() throws IOException { synchronized (lock) { checkNotClosed(); int ch = readChar(); if (lastWasCR && ch == '\n') { ch = readChar(); } lastWasCR = false; return ch; } }
public int read(char[] buffer, int offset, int length) throws IOException { synchronized (lock) { checkNotClosed(); Arrays.checkOffsetAndCount(buffer.length, offset, length); if (length == 0) {
/** * Indicates whether this reader is ready to be read without blocking. * * @return {@code true} if this reader will not block when {@code read} is * called, {@code false} if unknown or blocking will occur. * @throws IOException * if this reader is closed or some other I/O error occurs. * @see #read() * @see #read(char[], int, int) * @see #readLine() */ @Override public boolean ready() throws IOException { synchronized (lock) { checkNotClosed(); return ((end - pos) > 0) || in.ready(); } }
/** * Indicates whether this reader is ready to be read without blocking. * * @return {@code true} if this reader will not block when {@code read} is * called, {@code false} if unknown or blocking will occur. * @throws IOException * if this reader is closed or some other I/O error occurs. * @see #read() * @see #read(char[], int, int) * @see #readLine() */ @Override public boolean ready() throws IOException { synchronized (lock) { checkNotClosed(); return ((end - pos) > 0) || in.ready(); } }
/** * Indicates whether this reader is ready to be read without blocking. * * @return {@code true} if this reader will not block when {@code read} is * called, {@code false} if unknown or blocking will occur. * @throws IOException * if this reader is closed or some other I/O error occurs. * @see #read() * @see #read(char[], int, int) * @see #readLine() */ @Override public boolean ready() throws IOException { synchronized (lock) { checkNotClosed(); return ((end - pos) > 0) || in.ready(); } }
/** * Indicates whether this reader is ready to be read without blocking. * * @return {@code true} if this reader will not block when {@code read} is * called, {@code false} if unknown or blocking will occur. * @throws IOException * if this reader is closed or some other I/O error occurs. * @see #read() * @see #read(char[], int, int) * @see #readLine() */ @Override public boolean ready() throws IOException { synchronized (lock) { checkNotClosed(); return ((end - pos) > 0) || in.ready(); } }
/** * Indicates whether this reader is ready to be read without blocking. * * @return {@code true} if this reader will not block when {@code read} is * called, {@code false} if unknown or blocking will occur. * @throws IOException * if this reader is closed or some other I/O error occurs. * @see #read() * @see #read(char[], int, int) * @see #readLine() */ @Override public boolean ready() throws IOException { synchronized (lock) { checkNotClosed(); return ((end - pos) > 0) || in.ready(); } }
/** * Indicates whether this reader is ready to be read without blocking. * * @return {@code true} if this reader will not block when {@code read} is * called, {@code false} if unknown or blocking will occur. * @throws IOException * if this reader is closed or some other I/O error occurs. * @see #read() * @see #read(char[], int, int) * @see #readLine() */ @Override public boolean ready() throws IOException { synchronized (lock) { checkNotClosed(); return ((end - pos) > 0) || in.ready(); } }
/** * Indicates whether this reader is ready to be read without blocking. * * @return {@code true} if this reader will not block when {@code read} is * called, {@code false} if unknown or blocking will occur. * @throws IOException * if this reader is closed or some other I/O error occurs. * @see #read() * @see #read(char[], int, int) * @see #readLine() */ @Override public boolean ready() throws IOException { synchronized (lock) { checkNotClosed(); return ((end - pos) > 0) || in.ready(); } }
/** * Resets this reader's position to the last {@code mark()} location. * Invocations of {@code read()} and {@code skip()} will occur from this new * location. * * @throws IOException * if this reader is closed or no mark has been set. * @see #mark(int) * @see #markSupported() */ @Override public void reset() throws IOException { synchronized (lock) { checkNotClosed(); if (mark == -1) { throw new IOException("Invalid mark"); } this.pos = mark; this.lastWasCR = this.markedLastWasCR; } }
/** * Resets this reader's position to the last {@code mark()} location. * Invocations of {@code read()} and {@code skip()} will occur from this new * location. * * @throws IOException * if this reader is closed or no mark has been set. * @see #mark(int) * @see #markSupported() */ @Override public void reset() throws IOException { synchronized (lock) { checkNotClosed(); if (mark == -1) { throw new IOException("Invalid mark"); } this.pos = mark; this.lastWasCR = this.markedLastWasCR; } }
/** * Resets this reader's position to the last {@code mark()} location. * Invocations of {@code read()} and {@code skip()} will occur from this new * location. * * @throws IOException * if this reader is closed or no mark has been set. * @see #mark(int) * @see #markSupported() */ @Override public void reset() throws IOException { synchronized (lock) { checkNotClosed(); if (mark == -1) { throw new IOException("Invalid mark"); } this.pos = mark; this.lastWasCR = this.markedLastWasCR; } }
/** * Resets this reader's position to the last {@code mark()} location. * Invocations of {@code read()} and {@code skip()} will occur from this new * location. * * @throws IOException * if this reader is closed or no mark has been set. * @see #mark(int) * @see #markSupported() */ @Override public void reset() throws IOException { synchronized (lock) { checkNotClosed(); if (mark == -1) { throw new IOException("Invalid mark"); } this.pos = mark; this.lastWasCR = this.markedLastWasCR; } }
/** * Resets this reader's position to the last {@code mark()} location. * Invocations of {@code read()} and {@code skip()} will occur from this new * location. * * @throws IOException * if this reader is closed or no mark has been set. * @see #mark(int) * @see #markSupported() */ @Override public void reset() throws IOException { synchronized (lock) { checkNotClosed(); if (mark == -1) { throw new IOException("Invalid mark"); } this.pos = mark; this.lastWasCR = this.markedLastWasCR; } }
/** * Resets this reader's position to the last {@code mark()} location. * Invocations of {@code read()} and {@code skip()} will occur from this new * location. * * @throws IOException * if this reader is closed or no mark has been set. * @see #mark(int) * @see #markSupported() */ @Override public void reset() throws IOException { synchronized (lock) { checkNotClosed(); if (mark == -1) { throw new IOException("Invalid mark"); } this.pos = mark; this.lastWasCR = this.markedLastWasCR; } }