Java 8 PushbackReader - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 PushbackReader class.

This code example shows how to use the following methods:read, unread
  private class CsvIndex implements Index { 
    @Override 
    public boolean done() { 
      char c = '\0';
      try { 
        c = (char) stream.read();
        stream.unread(c);
      } catch (IOException ex) {
      } 
      return (c == '}') ? true : false;
    } 
    @Override 
    public void incr() {} 
  } 
     
  private void throwExceptionOnError(String tag) throws IOException {
    throw new IOException("Error deserializing "+tag);
  } 
     
  private String readField(String tag) throws IOException {
7
CodeRank
This code example shows how to use the following methods:
     * @param presentation 
     *            If not <code>null</code>, formattings will be applied to the 
     *            presentation. 
     */ 
    public HTML2TextReader(final Reader reader, final TextPresentation presentation) {
        super(new PushbackReader(reader));
        fTextPresentation = presentation;
    } 
 
    @Override 
    public int read() throws IOException { 
        final int c = super.read();
        if (c != -1) {
            ++fCounter;
        } 
        return c;
    } 
 
    protected void startBold() { 
        if (fBold == 0) {
6
CodeRank
This code example shows how to use the following methods:read, skip, unread
     * java.io.PushbackReader#unread(int) 
     */ 
    public void test_unreadI() throws IOException {
        PushbackReader tobj;
 
        tobj = new PushbackReader(underlying);
        tobj.unread(23); // Why does this work?!?
        tobj.skip(2);
        tobj.unread(23);
        assertEquals("Wrong value read!", 23, tobj.read());
        tobj.unread(13);
        try { 
            tobj.unread(13);
            fail("IOException not thrown (ACTUALLY NOT SURE WHETHER IT REALLY MUST BE THROWN!).");
        } catch (IOException e) {
            // expected 
        } 
    } 
 
    /** 
6
CodeRank
This code example shows how to use the following methods:read, unread
      } 
    } 
  } 
     
  public void endRecord(String tag) throws IOException {
    char c = (char) stream.read();
    if (tag == null || "".equals(tag)) {
      if (c != '\n' && c != '\r') {
        throw new IOException("Error deserializing record.");
      } else { 
        return; 
      } 
    } 
         
    if (c != '}') {
      throw new IOException("Error deserializing "+tag);
    } 
    c = (char) stream.read();
    if (c != ',') {
      stream.unread(c);

6
CodeRank
This code example shows how to use the following methods:read, unread
     
  private class CsvIndex implements Index { 
    public boolean done() { 
      char c = '\0';
      try { 
        c = (char) stream.read();
        stream.unread(c);
      } catch (IOException ex) {
      } 
      return (c == '}') ? true : false;
    } 
    public void incr() {} 
  } 
     
  private void throwExceptionOnError(String tag) throws IOException {
    throw new IOException("Error deserializing "+tag);
  } 
     
  private String readField(String tag) throws IOException {
    try { 
6
CodeRank
This code example shows how to use the following methods:read, skip, unread
     * java.io.PushbackReader#unread(int) 
     */ 
    public void test_unreadI() throws IOException { 
        PushbackReader tobj;
 
        tobj = new PushbackReader(underlying);
        tobj.unread(23); // Why does this work?!?
        tobj.skip(2);
        tobj.unread(23);
        assertEquals("Wrong value read!", 23, tobj.read());
        tobj.unread(13);
        try { 
            tobj.unread(13);
            fail("IOException not thrown (ACTUALLY NOT SURE WHETHER IT REALLY MUST BE THROWN!).");
        } catch (IOException e) {
            // expected 
        } 
    } 
 
    /** 
5
CodeRank
This code example shows how to use the following methods:
     * @return the parsed result as an AST tree 
     * @throws Exception in case of a parsing error 
     */ 
    public Start parse(String stmt) throws Exception 
    { 
        Parser p = new Parser(new Lexer(new PushbackReader(new StringReader(stmt)))); 
        Start start = p.parse(); 
        return start; 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:read, unread
            } 
        } 
    } 
 
    public void endRecord(String tag) throws IOException {
        char c = (char) stream.read();
        if (tag == null || "".equals(tag)) {
            if (c != '\n' && c != '\r') {
                throw new IOException("Error deserializing record.");
            } else { 
                return; 
            } 
        } 
 
        if (c != '}') {
            throw new IOException("Error deserializing " + tag);
        } 
        c = (char) stream.read();
        if (c != ',') {
            stream.unread(c);

5
CodeRank
This code example shows how to use the following methods:read, skip, unread
     * java.io.PushbackReader#unread(int) 
     */ 
    public void test_unreadI() throws IOException { 
        PushbackReader tobj;
 
        tobj = new PushbackReader(underlying);
        tobj.unread(23); // Why does this work?!?
        tobj.skip(2);
        tobj.unread(23);
        assertEquals("Wrong value read!", 23, tobj.read());
        tobj.unread(13);
        try { 
            tobj.unread(13);
            fail("IOException not thrown (ACTUALLY NOT SURE WHETHER IT REALLY MUST BE THROWN!).");
        } catch (IOException e) {
            // expected 
        } 
    } 
 
    /** 
5
CodeRank
This code example shows how to use the following methods:
     * @param presentation 
     *            If not <code>null</code>, formattings will be applied to the 
     *            presentation. 
     */ 
    public HTML2TextReader(final Reader reader, final TextPresentation presentation) {
        super(new PushbackReader(reader));
        fTextPresentation = presentation;
    } 
 
    @Override 
    public int read() throws IOException {
        final int c = super.read();
        if (c != -1) {
            ++fCounter;
        } 
        return c;
    } 
 
    protected void startBold() { 
        if (fBold == 0) {
5
CodeRank
See Code Examples for Java 8 PushbackReader Methods: