/** * Indicates whether this reader is ready to be read without blocking. This * implementation always returns {@code true}. * * @return always {@code true}. * @throws IOException * if this reader is closed. * @see #read() * @see #read(char[], int, int) */ @Override public boolean ready() throws IOException { synchronized (lock) { checkNotClosed(); return true; } }
/** * Resets this reader's position to the last {@code mark()} location. * Invocations of {@code read()} and {@code skip()} will occur from this new * location. If this reader has not been marked, it is reset to the * beginning of the source string. * * @throws IOException * if this reader is closed. * @see #mark(int) * @see #markSupported() */ @Override public void reset() throws IOException { synchronized (lock) { checkNotClosed(); pos = markpos != -1 ? markpos : 0; } }
public long skip(long charCount) throws IOException { synchronized (lock) { checkNotClosed();
/** * Reads a single character from the source string and returns it as an * integer with the two higher-order bytes set to 0. Returns -1 if the end * of the source string has been reached. * * @return the character read or -1 if the end of the source string has been * reached. * @throws IOException * if this reader is closed. */ @Override public int read() throws IOException { synchronized (lock) { checkNotClosed(); if (pos != count) { return str.charAt(pos++); } return -1; } }
/** * Sets a mark position in this reader. The parameter {@code readLimit} is * ignored for this class. Calling {@code reset()} will reposition the * reader back to the marked position. * * @param readLimit * ignored for {@code StringReader} instances. * @throws IllegalArgumentException * if {@code readLimit < 0}. * @throws IOException * if this reader is closed. * @see #markSupported() * @see #reset() */ @Override public void mark(int readLimit) throws IOException { if (readLimit < 0) { throw new IllegalArgumentException("readLimit < 0: " + readLimit); } synchronized (lock) { checkNotClosed(); markpos = pos; } }
/** * Reads up to {@code count} characters from the source string and stores * them at {@code offset} in the character array {@code buffer}. Returns the * number of characters actually read or -1 if the end of the source string * has been reached. * * @throws IndexOutOfBoundsException if {@code offset < 0 || count < 0 || offset + count > buffer.length}. * @throws IOException * if this reader is closed. */ @Override public int read(char[] buffer, int offset, int count) throws IOException { synchronized (lock) { checkNotClosed(); Arrays.checkOffsetAndCount(buffer.length, offset, count); if (count == 0) { return 0; } if (pos == this.count) { return -1; } int end = pos + count > this.count ? this.count : pos + count; str.getChars(pos, end, buffer, offset); int read = end - pos; pos = end; return read; } }
/** * Indicates whether this reader is ready to be read without blocking. This * implementation always returns {@code true}. * * @return always {@code true}. * @throws IOException * if this reader is closed. * @see #read() * @see #read(char[], int, int) */ @Override public boolean ready() throws IOException { synchronized (lock) { checkNotClosed(); return true; } }
/** * Indicates whether this reader is ready to be read without blocking. This * implementation always returns {@code true}. * * @return always {@code true}. * @throws IOException * if this reader is closed. * @see #read() * @see #read(char[], int, int) */ @Override public boolean ready() throws IOException { synchronized (lock) { checkNotClosed(); return true; } }
/** * Indicates whether this reader is ready to be read without blocking. This * implementation always returns {@code true}. * * @return always {@code true}. * @throws IOException if this reader is closed. * @see #read() * @see #read(char[], int, int) */ @Override public boolean ready() throws IOException { synchronized (lock) { checkNotClosed(); return true; } }
/** * Resets this reader's position to the last {@code mark()} location. * Invocations of {@code read()} and {@code skip()} will occur from this new * location. If this reader has not been marked, it is reset to the * beginning of the source string. * * @throws IOException * if this reader is closed. * @see #mark(int) * @see #markSupported() */ @Override public void reset() throws IOException { synchronized (lock) { checkNotClosed(); pos = markpos != -1 ? markpos : 0; } }
/** * Indicates whether this reader is ready to be read without blocking. This * implementation always returns {@code true}. * * @return always {@code true}. * @throws IOException * if this reader is closed. * @see #read() * @see #read(char[], int, int) */ @Override public boolean ready() throws IOException { synchronized (lock) { checkNotClosed(); return true; } }
/** * Indicates whether this reader is ready to be read without blocking. This * implementation always returns {@code true}. * * @return always {@code true}. * @throws IOException * if this reader is closed. * @see #read() * @see #read(char[], int, int) */ @Override public boolean ready() throws IOException { synchronized (lock) { checkNotClosed(); return true; } }
/** * Indicates whether this reader is ready to be read without blocking. This * implementation always returns {@code true}. * * @return always {@code true}. * @throws IOException * if this reader is closed. * @see #read() * @see #read(char[], int, int) */ @Override public boolean ready() throws IOException { synchronized (lock) { checkNotClosed(); return true; } }
/** * Resets this reader's position to the last {@code mark()} location. * Invocations of {@code read()} and {@code skip()} will occur from this new * location. If this reader has not been marked, it is reset to the * beginning of the source string. * * @throws IOException if this reader is closed. * @see #mark(int) * @see #markSupported() */ @Override public void reset() throws IOException { synchronized (lock) { checkNotClosed(); pos = markpos != -1 ? markpos : 0; } }
/** * Resets this reader's position to the last {@code mark()} location. * Invocations of {@code read()} and {@code skip()} will occur from this new * location. If this reader has not been marked, it is reset to the * beginning of the source string. * * @throws IOException * if this reader is closed. * @see #mark(int) * @see #markSupported() */ @Override public void reset() throws IOException { synchronized (lock) { checkNotClosed(); pos = markpos != -1 ? markpos : 0; } }
/** * Resets this reader's position to the last {@code mark()} location. * Invocations of {@code read()} and {@code skip()} will occur from this new * location. If this reader has not been marked, it is reset to the * beginning of the source string. * * @throws IOException * if this reader is closed. * @see #mark(int) * @see #markSupported() */ @Override public void reset() throws IOException { synchronized (lock) { checkNotClosed(); pos = markpos != -1 ? markpos : 0; } }
/** * Resets this reader's position to the last {@code mark()} location. * Invocations of {@code read()} and {@code skip()} will occur from this new * location. If this reader has not been marked, it is reset to the * beginning of the source string. * * @throws IOException * if this reader is closed. * @see #mark(int) * @see #markSupported() */ @Override public void reset() throws IOException { synchronized (lock) { checkNotClosed(); pos = markpos != -1 ? markpos : 0; } }
/** * Sets a mark position in this reader. The parameter {@code readLimit} is * ignored for this class. Calling {@code reset()} will reposition the * reader back to the marked position. * * @param readLimit ignored for {@code StringReader} instances. * @throws IllegalArgumentException if {@code readLimit < 0}. * @throws IOException if this reader is closed. * @see #markSupported() * @see #reset() */ @Override public void mark(int readLimit) throws IOException { if (readLimit < 0) { throw new IllegalArgumentException("readLimit < 0: " + readLimit); } synchronized (lock) { checkNotClosed(); markpos = pos; } }
/** * Reads a single character from the source string and returns it as an * integer with the two higher-order bytes set to 0. Returns -1 if the end * of the source string has been reached. * * @return the character read or -1 if the end of the source string has been * reached. * @throws IOException if this reader is closed. */ @Override public int read() throws IOException { synchronized (lock) { checkNotClosed(); if (pos != count) { return str.charAt(pos++); } return -1; } }
/** * Reads a single character from the source string and returns it as an * integer with the two higher-order bytes set to 0. Returns -1 if the end * of the source string has been reached. * * @return the character read or -1 if the end of the source string has been * reached. * @throws IOException * if this reader is closed. */ @Override public int read() throws IOException { synchronized (lock) { checkNotClosed(); if (pos != count) { return str.charAt(pos++); } return -1; } }