Java Code Examples for java.io.Reader#markSupported()
The following examples show how to use
java.io.Reader#markSupported() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RemoteSession.java From openhab1-addons with Eclipse Public License 2.0 | 6 votes |
private static char[] readCharArray(Reader reader) throws IOException { if (reader.markSupported()) { reader.mark(1024); } int length = reader.read(); int delimiter = reader.read(); if (delimiter != 0) { if (reader.markSupported()) { reader.reset(); } throw new IOException("Unsupported reply exception"); } char[] buffer = new char[length]; reader.read(buffer); return buffer; }
Example 2
Source File: JSONTokener.java From mil-sym-java with Apache License 2.0 | 5 votes |
/** * Construct a JSONTokener from a Reader. * * @param reader A reader. */ public JSONTokener(Reader reader) { this.reader = reader.markSupported() ? reader : new BufferedReader(reader); this.eof = false; this.usePrevious = false; this.previous = 0; this.index = 0; this.character = 1; this.line = 1; }
Example 3
Source File: JSONTokener.java From mil-sym-android with Apache License 2.0 | 5 votes |
/** * Construct a JSONTokener from a Reader. * * @param reader A reader. */ public JSONTokener(Reader reader) { this.reader = reader.markSupported() ? reader : new BufferedReader(reader); this.eof = false; this.usePrevious = false; this.previous = 0; this.index = 0; this.character = 1; this.line = 1; }
Example 4
Source File: JSONTokenizer.java From light-task-scheduler with Apache License 2.0 | 5 votes |
public JSONTokenizer(Reader reader) { this.reader = reader.markSupported() ? reader : new BufferedReader(reader); this.eof = false; this.usePrevious = false; this.previous = 0; this.index = 0; this.character = 1; this.line = 1; }
Example 5
Source File: JSONTokener.java From JMCCC with MIT License | 5 votes |
/** * Construct a JSONTokener from a Reader. * * @param reader A reader. */ public JSONTokener(Reader reader) { this.reader = reader.markSupported() ? reader : new BufferedReader(reader); this.eof = false; this.usePrevious = false; this.previous = 0; this.index = 0; this.character = 1; this.line = 1; }
Example 6
Source File: JSONTokener.java From javapns-jdk16 with GNU Lesser General Public License v3.0 | 5 votes |
/** * Construct a JSONTokener from a string. * * @param reader A reader. */ public JSONTokener(Reader reader) { this.reader = reader.markSupported() ? reader : new BufferedReader(reader); this.useLastChar = false; this.index = 0; }
Example 7
Source File: AVA.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static boolean trailingSpace(Reader in) throws IOException { boolean trailing = false; if (!in.markSupported()) { // oh well return true; } else { // make readAheadLimit huge - // in practice, AVA was passed a StringReader from X500Name, // and StringReader ignores readAheadLimit anyways in.mark(9999); while (true) { int nextChar = in.read(); if (nextChar == -1) { trailing = true; break; } else if (nextChar == ' ') { continue; } else if (nextChar == '\\') { int followingChar = in.read(); if (followingChar != ' ') { trailing = false; break; } } else { trailing = false; break; } } in.reset(); return trailing; } }
Example 8
Source File: AVA.java From hottub with GNU General Public License v2.0 | 5 votes |
private static boolean trailingSpace(Reader in) throws IOException { boolean trailing = false; if (!in.markSupported()) { // oh well return true; } else { // make readAheadLimit huge - // in practice, AVA was passed a StringReader from X500Name, // and StringReader ignores readAheadLimit anyways in.mark(9999); while (true) { int nextChar = in.read(); if (nextChar == -1) { trailing = true; break; } else if (nextChar == ' ') { continue; } else if (nextChar == '\\') { int followingChar = in.read(); if (followingChar != ' ') { trailing = false; break; } } else { trailing = false; break; } } in.reset(); return trailing; } }
Example 9
Source File: JSONTokener.java From alipay-java-sdk with MIT License | 5 votes |
/** * Construct a JSONTokener from a Reader. * * @param reader A reader. */ public JSONTokener(Reader reader) { this.reader = reader.markSupported() ? reader : new BufferedReader(reader); this.eof = false; this.usePrevious = false; this.previous = 0; this.index = 0; this.character = 1; this.line = 1; }
Example 10
Source File: JSONTokener.java From RipplePower with Apache License 2.0 | 5 votes |
/** * Construct a JSONTokener from a Reader. * * @param reader * A reader. */ public JSONTokener(Reader reader) { this.reader = reader.markSupported() ? reader : new BufferedReader( reader); this.eof = false; this.usePrevious = false; this.previous = 0; this.index = 0; this.character = 1; this.line = 1; }
Example 11
Source File: AVA.java From j2objc with Apache License 2.0 | 5 votes |
private static boolean trailingSpace(Reader in) throws IOException { boolean trailing = false; if (!in.markSupported()) { // oh well return true; } else { // make readAheadLimit huge - // in practice, AVA was passed a StringReader from X500Name, // and StringReader ignores readAheadLimit anyways in.mark(9999); while (true) { int nextChar = in.read(); if (nextChar == -1) { trailing = true; break; } else if (nextChar == ' ') { continue; } else if (nextChar == '\\') { int followingChar = in.read(); if (followingChar != ' ') { trailing = false; break; } } else { trailing = false; break; } } in.reset(); return trailing; } }
Example 12
Source File: JSONTokener.java From sc2gears with Apache License 2.0 | 5 votes |
/** * Construct a JSONTokener from a reader. * * @param reader A reader. */ public JSONTokener(Reader reader) { this.reader = reader.markSupported() ? reader : new BufferedReader(reader); this.eof = false; this.usePrevious = false; this.previous = 0; this.index = 0; this.character = 1; this.line = 1; }
Example 13
Source File: JSONTokener.java From yacy_grid_mcp with GNU Lesser General Public License v2.1 | 5 votes |
/** * Construct a JSONTokener from a Reader. The caller must close the Reader. * * @param reader A reader. */ public JSONTokener(Reader reader) { this.reader = reader.markSupported() ? reader : new BufferedReader(reader); this.eof = false; this.usePrevious = false; this.previous = 0; this.index = 0; this.character = 1; this.characterPreviousLine = 0; this.line = 1; }
Example 14
Source File: AVA.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static boolean trailingSpace(Reader in) throws IOException { boolean trailing = false; if (!in.markSupported()) { // oh well return true; } else { // make readAheadLimit huge - // in practice, AVA was passed a StringReader from X500Name, // and StringReader ignores readAheadLimit anyways in.mark(9999); while (true) { int nextChar = in.read(); if (nextChar == -1) { trailing = true; break; } else if (nextChar == ' ') { continue; } else if (nextChar == '\\') { int followingChar = in.read(); if (followingChar != ' ') { trailing = false; break; } } else { trailing = false; break; } } in.reset(); return trailing; } }
Example 15
Source File: AVA.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static boolean trailingSpace(Reader in) throws IOException { boolean trailing = false; if (!in.markSupported()) { // oh well return true; } else { // make readAheadLimit huge - // in practice, AVA was passed a StringReader from X500Name, // and StringReader ignores readAheadLimit anyways in.mark(9999); while (true) { int nextChar = in.read(); if (nextChar == -1) { trailing = true; break; } else if (nextChar == ' ') { continue; } else if (nextChar == '\\') { int followingChar = in.read(); if (followingChar != ' ') { trailing = false; break; } } else { trailing = false; break; } } in.reset(); return trailing; } }
Example 16
Source File: JSONTokener.java From EconomyAPI with GNU General Public License v3.0 | 5 votes |
/** * Construct a JSONTokener from a Reader. * * @param reader A reader. */ public JSONTokener(Reader reader) { this.reader = reader.markSupported() ? reader : new BufferedReader(reader); this.eof = false; this.usePrevious = false; this.previous = 0; this.index = 0; this.character = 1; this.line = 1; }
Example 17
Source File: JSONTokener.java From equalize-xpi-modules with MIT License | 5 votes |
/** * Construct a JSONTokener from a Reader. * * @param reader A reader. */ public JSONTokener(Reader reader) { this.reader = reader.markSupported() ? reader : new BufferedReader(reader); this.eof = false; this.usePrevious = false; this.previous = 0; this.index = 0; this.character = 1; this.line = 1; }
Example 18
Source File: SortedJSONTokener.java From codenjoy with GNU General Public License v3.0 | 5 votes |
/** * Construct a JSONTokener from a Reader. * * @param reader A reader. */ public SortedJSONTokener(Reader reader) { this.reader = reader.markSupported() ? reader : new BufferedReader(reader); this.eof = false; this.usePrevious = false; this.previous = 0; this.index = 0; this.character = 1; this.line = 1; }
Example 19
Source File: TemplateEngine.java From commons-jexl with Apache License 2.0 | 4 votes |
/** * Read lines from a (buffered / mark-able) reader keeping all new-lines and line-feeds. * @param reader the reader * @return the line iterator */ protected static Iterator<CharSequence> readLines(final Reader reader) { if (!reader.markSupported()) { throw new IllegalArgumentException("mark support in reader required"); } return new Iterator<CharSequence>() { private CharSequence next = doNext(); private CharSequence doNext() { StringBuffer strb = new StringBuffer(64); // CSOFF: MagicNumber int c; boolean eol = false; try { while ((c = reader.read()) >= 0) { if (eol) {// && (c != '\n' && c != '\r')) { reader.reset(); break; } if (c == '\n') { eol = true; } strb.append((char) c); reader.mark(1); } } catch (IOException xio) { return null; } return strb.length() > 0 ? strb : null; } @Override public boolean hasNext() { return next != null; } @Override public CharSequence next() { CharSequence current = next; if (current != null) { next = doNext(); } return current; } @Override public void remove() { throw new UnsupportedOperationException("Not supported."); } }; }
Example 20
Source File: IOGroovyMethods.java From groovy with Apache License 2.0 | 3 votes |
/** * Read a single, whole line from the given Reader. This method is designed for use with * Readers that support the {@code mark()} operation like BufferReader. It has a fallback * behavior for Readers that don't support mark() but the behavior doesn't correctly * detect multi-character line termination (e.g. carriage return followed by linefeed). * We recommend for Readers that don't support mark() you consider using one of the * following methods instead: eachLine, readLines, or iterator. * * @param self a Reader * @return a line * @throws IOException if an IOException occurs. * @see #readLines(java.io.Reader) * @see #iterator(java.io.Reader) * @see #eachLine(java.io.Reader, groovy.lang.Closure) * @since 1.0 */ public static String readLine(Reader self) throws IOException { if (self instanceof BufferedReader) { BufferedReader br = (BufferedReader) self; return br.readLine(); } if (self.markSupported()) { return readLineFromReaderWithMark(self); } return readLineFromReaderWithoutMark(self); }