Java 8 CharArrayReader - 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 CharArrayReader class.

This code example shows how to use the following methods:mark, read, reset, skip
 
    /** 
     * @tests java.io.CharArrayReader#mark(int) 
     */ 
    public void test_markI() throws IOException { 
        cr = new CharArrayReader(hw);
        cr.skip(5L);
        cr.mark(100);
        cr.read();
        cr.reset();
        assertEquals("Failed to mark correct position", 'W', cr.read());
    } 
 
    /** 
     * @tests java.io.CharArrayReader#markSupported() 
     */ 
    public void test_markSupported() { 
        cr = new CharArrayReader(hw);
        assertTrue("markSupported returned false", cr.markSupported());
    } 
7
CodeRank
This code example shows how to use the following methods:close, mark, read, reset, skip
 
    /** 
     * java.io.CharArrayReader#reset() 
     */ 
    public void test_reset() throws IOException {
        cr = new CharArrayReader(hw);
        cr.skip(5L);
        cr.mark(100);
        cr.read();
        cr.reset();
        assertEquals("Test 1: Reset failed to return to marker position.",
                'W', cr.read());
 
        cr.close();
        try { 
            cr.reset();
            fail("Test 2: IOException expected.");
        } catch (IOException e) {
            // Expected. 
        } 
    } 
6
CodeRank
This code example shows how to use the following methods:mark, read, reset, skip
 
    /** 
     * @tests java.io.CharArrayReader#mark(int) 
     */ 
    public void test_markI() throws IOException { 
        cr = new CharArrayReader(hw);
        cr.skip(5L);
        cr.mark(100);
        cr.read();
        cr.reset();
        assertEquals("Failed to mark correct position", 'W', cr.read());
    } 
 
    /** 
     * @tests java.io.CharArrayReader#markSupported() 
     */ 
    public void test_markSupported() { 
        cr = new CharArrayReader(hw);
        assertTrue("markSupported returned false", cr.markSupported());
    } 
6
CodeRank
This code example shows how to use the following methods:
    public void testHasPythonShebang() { 
        String s = "" +
                "#!bla\n" + 
                "\n" + 
                ""; 
        CharArrayReader reader = new CharArrayReader(s.toCharArray());
        assertFalse(FileUtils.hasPythonShebang(reader));
    } 
 
    public void testHasPythonShebang1() { 
        String s = "" +
                "#!python\n" + 
                "\n" + 
                ""; 
        CharArrayReader reader = new CharArrayReader(s.toCharArray());
        assertTrue(FileUtils.hasPythonShebang(reader));
    } 
 
    public void testHasPythonShebang2() { 
        String s = "" +
6
CodeRank
This code example shows how to use the following methods:close, mark, read, reset, skip
 
    /** 
     * java.io.CharArrayReader#mark(int) 
     */ 
    public void test_markI() throws IOException { 
        cr = new CharArrayReader(hw);
        cr.skip(5L);
        cr.mark(100);
        cr.read();
        cr.reset();
        assertEquals("Test 1: Failed to mark correct position;",
                'W', cr.read());
 
        cr.close();
        try { 
            cr.mark(100);
            fail("Test 2: IOException expected.");
        } catch (IOException e) {
            // Expected. 
        } 
    } 
6
CodeRank
This code example shows how to use the following methods:close, mark, read, reset, skip
 
    /** 
     * java.io.CharArrayReader#mark(int) 
     */ 
    public void test_markI() throws IOException { 
        cr = new CharArrayReader(hw);
        cr.skip(5L);
        cr.mark(100);
        cr.read();
        cr.reset();
        assertEquals("Test 1: Failed to mark correct position;",
                'W', cr.read());
 
        cr.close();
        try { 
            cr.mark(100);
            fail("Test 2: IOException expected.");
        } catch (IOException e) {
            // Expected. 
        } 
    } 
6
CodeRank
This code example shows how to use the following methods:
 
public class TimeoutReaderTest { 
 
	@Test 
	public void testOk() throws Exception { 
		CharArrayReader bin = new CharArrayReader(
				"this is my test\n".toCharArray());
		TimeoutReader in = new TimeoutReader(bin, 500l);
		BufferedReader data = new BufferedReader(in);
		assertEquals("this is my test", data.readLine());
		try { 
			data.readLine();
			fail("IllegalStateException expected"); 
		} catch (IllegalStateException e) {
			assertEquals("timeout", e.getMessage());
		} 
		data.close();
	} 
 
	@Test 
6
CodeRank
This code example shows how to use the following methods:
        assertEquals("utf-8", encoding);
    } 
 
    public void testGetEncoding6() { 
        String s = "" + "#coding: utf-8;\n" + "\n" + "";
        CharArrayReader reader = new CharArrayReader(s.toCharArray());
        String encoding = FileUtils.getPythonFileEncoding(reader, null);
        assertEquals("utf-8", encoding);
    } 
 
    public void testGetEncoding7() { 
        String s = "" + "#coding: utf8;\n" + "\n" + "";
        CharArrayReader reader = new CharArrayReader(s.toCharArray());
        String encoding = FileUtils.getPythonFileEncoding(reader, null);
        assertEquals("utf8", encoding);
    } 
 
    public void testGetEncoding8() { 
        String s = "" + "#coding: iso-latin-1-unix;\n" + "\n" + "";
        CharArrayReader reader = new CharArrayReader(s.toCharArray());
6
CodeRank
This code example shows how to use the following methods:
    // capture the output of the XMLWriter 
    final CharArrayWriter w = new CharArrayWriter();
    XMLWriter.writeResponse(w,request,response);
     
    // and write transformed result to our writer 
    final Reader r = new BufferedReader(new CharArrayReader(w.toCharArray()));
    final StreamSource source = new StreamSource(r);
    final StreamResult result = new StreamResult(writer);
    try { 
      t.transform(source, result);
    } catch(TransformerException te) {
      throw new IOException("XSLT transformation error", te);
    } 
  } 
   
  /** Get Transformer from request context, or from TransformerProvider. 
   *  This allows either getContentType(...) or write(...) to instantiate the Transformer, 
   *  depending on which one is called first, then the other one reuses the same Transformer 
   */ 
  protected Transformer getTransformer(SolrQueryRequest request) throws IOException {
5
CodeRank
This code example shows how to use the following methods:
     * Lexer and adds the tokens obtained to an ArrayList. 
     */ 
    @Override 
    public void parse(Segment segment, int ofst, List<Token> tokens) {
        try { 
            CharArrayReader reader = new CharArrayReader(segment.array, segment.offset, segment.count);
            yyreset(reader);
            this.offset = ofst;
            for (Token t = yylex(); t != null; t = yylex()) {
                tokens.add(t);
            } 
        } catch (IOException ex) {
            Logger.getLogger(DefaultJFlexLexer.class.getName()).log(Level.SEVERE, null, ex);
        } 
    } 
 
    /** 
     * This will be called to reset the the lexer. 
     * This is created automatically by JFlex. 
     * @param reader 
5
CodeRank
See Code Examples for Java 8 CharArrayReader Methods: