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

This code example shows how to use the following methods:
 
    @Override 
    public T unmarshall(Class<T> clazz, String obj) {
        try { 
            JsonFactory jsonFactory = new MappingJsonFactory();
            JsonParser jsonParser = jsonFactory.createJsonParser(new StringReader(obj));
            return jsonParser.readValueAs(clazz);
        } catch ( Exception e ) {
            throw new RuntimeException(e);
        } 
    } 
 
} 
10
CodeRank
This code example shows how to use the following methods:
     */ 
    List<ModelNode> parse(String subsystemXml) throws XMLStreamException, IOException {
        String xml = "<test xmlns=\"" + TEST_NAMESPACE + "\">"
                + ModelTestUtils.readResource(getClass(), subsystemXml)
                + "</test>"; 
        final XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xml));
        final List<ModelNode> operationList = new ArrayList<ModelNode>();
        xmlMapper.parseDocument(operationList, reader);
        return operationList;
    } 
 
    @Test 
    public void testParseMissingPasswordJSSE() throws Exception { 
        try { 
            parse("securityErrorMissingPassword.xml"); 
            Assert.fail("There should have been an error.");
        } catch (XMLStreamException ex) {
            Assert.assertTrue(ex.getMessage(), ex.getMessage().contains("JBAS013319"));
        } 
    } 
9
CodeRank
This code example shows how to use the following methods:
        TokenFilterFactory tokenFilter = analysisService.tokenFilter("keep_numbers"); 
        assertThat(tokenFilter, instanceOf(KeepTypesFilterFactory.class)); 
        String source = "Hello 123 world"; 
        String[] expected = new String[]{"123"}; 
        Tokenizer tokenizer = new StandardTokenizer(); 
        tokenizer.setReader(new StringReader(source)); 
        assertTokenStreamContents(tokenFilter.create(tokenizer), expected, new int[]{2}); 
    } 
} 
9
CodeRank
This code example shows how to use the following methods:
    } 
 
    @Override 
    public Reader getReader() 
            throws IOException { 
        return new StringReader(getDetail()); 
    } 
} 
9
CodeRank
This code example shows how to use the following methods:
   * @param xmlString a string representation of an XML document 
   * @return an {@code AndroidManifestReader} for the XML document 
   * @throws IOException 
   */ 
  public static AndroidManifestReader forString(String xmlString) throws IOException {
    return forReader(new StringReader(xmlString));
  } 
 
  private static AndroidManifestReader forReader(Reader reader) throws IOException {
    return new DefaultAndroidManifestReader(new InputSource(reader));
  } 
 
} 
9
CodeRank
This code example shows how to use the following methods:mark, read, reset, skip
	/** 
	 * @tests java.io.StringReader#mark(int) 
	 */ 
	public void test_markI() throws Exception { 
		// Test for method void java.io.StringReader.mark(int) 
                sr = new StringReader(testString);
                sr.skip(5);
                sr.mark(0);
                sr.skip(5);
                sr.reset();
                char[] buf = new char[10];
                sr.read(buf, 0, 2);
                assertTrue("Failed to return to mark", new String(buf, 0, 2)
                                .equals(testString.substring(5, 7)));
	} 
 
	/** 
	 * @tests java.io.StringReader#markSupported() 
	 */ 
	public void test_markSupported() { 
8
CodeRank
This code example shows how to use the following methods:
        String template = "GET _search {\"query\": " + "{\"boosting\": {"
                + "\"positive\": {\"match\": {\"body\": \"gift\"}}," 
                + "\"negative\": {\"term\": {\"body\": {\"value\": \"solr\"}" 
                + "}}, \"negative_boost\": {{boost_val}} } }}"; 
        MustacheFactory f = new DefaultMustacheFactory();
        Mustache mustache = f.compile(new StringReader(template), "example");
        StringWriter writer = new StringWriter();
        mustache.execute(writer, scopes);
        writer.flush();
        assertEquals( 
                "Mustache templating broken", 
                "GET _search {\"query\": {\"boosting\": {\"positive\": {\"match\": {\"body\": \"gift\"}}," 
                        + "\"negative\": {\"term\": {\"body\": {\"value\": \"solr\"}}}, \"negative_boost\": 0.2 } }}", 
                writer.toString());
    } 
} 
9
CodeRank
This code example shows how to use the following methods:
            SAXParser sp;
            sp = spf.newSAXParser();
            XMLReader xr = sp.getXMLReader();
 
            xr.setContentHandler(parser);
            StringReader sr = new StringReader(wsContent);
            InputSource is = new InputSource(sr);
            xr.parse(is);
        } catch (ParserConfigurationException e) {
            Log.e(TAG, "ParserConfigurationException", e);
            throw new DataException(e);
        } catch (SAXException e) {
            Log.e(TAG, "SAXException", e);
            throw new DataException(e);
        } catch (IOException e) {
            Log.e(TAG, "IOException", e);
            throw new DataException(e);
        } 
        return parser.mPersonList;
    } 
9
CodeRank
This code example shows how to use the following methods:
                .build()); 
        TokenFilterFactory tokenFilter = analysisService.tokenFilter("my_ascii_folding"); 
        String source = "Ansprüche"; 
        String[] expected = new String[]{"Anspruche"}; 
        Tokenizer tokenizer = new WhitespaceTokenizer(); 
        tokenizer.setReader(new StringReader(source)); 
        assertTokenStreamContents(tokenFilter.create(tokenizer), expected); 
    } 
 
    @Test 
    public void testPreserveOriginal() throws IOException { 
        AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromSettings(settingsBuilder() 
                .put("index.analysis.filter.my_ascii_folding.type", "asciifolding") 
                .put("index.analysis.filter.my_ascii_folding.preserve_original", true) 
                .build()); 
        TokenFilterFactory tokenFilter = analysisService.tokenFilter("my_ascii_folding"); 
        String source = "Ansprüche"; 
        String[] expected = new String[]{"Anspruche", "Ansprüche"}; 
        Tokenizer tokenizer = new WhitespaceTokenizer(); 
        tokenizer.setReader(new StringReader(source)); 
9
CodeRank
This code example shows how to use the following methods:
   
  private static XmlPullParser buildParser(CharSequence contents) throws XmlPullParserException {
    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    factory.setNamespaceAware(true);
    XmlPullParser xpp = factory.newPullParser();
    xpp.setInput(new StringReader(contents.toString()));
    return xpp;
  } 
 
} 
9
CodeRank

Related Java 8 StringReader Questions & Answers:

Other Java 8 StringReader Examples

15:	         XmlPullParser xpp = factory.newPullParser();
16:	
17:	         xpp.setInput(new StringReader ("<foo>Hello World!</foo>"));
18:	         int eventType = xpp.getEventType();
19:	         while (eventType != XmlPullParser.END_DOCUMENT) {

Read More

6:	
7:				InputSource is = new InputSource();
8:			        is.setCharacterStream(new StringReader(xml));
9:			        doc = db.parse(is); 
10:

Read More

69:				InputSource is = new InputSource();
70:			        is.setCharacterStream(new StringReader(xml));
71:			        doc = db.parse(is); 
72:	
73:				} catch (ParserConfigurationException e) {

Read More

69:				InputSource is = new InputSource();
70:			        is.setCharacterStream(new StringReader(xml));
71:			        doc = db.parse(is); 
72:	
73:				} catch (ParserConfigurationException e) {

Read More

See Code Examples for Java 8 StringReader Methods: