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

This code example shows how to use the following methods:
        if (inputStream == null) {
            throw new RuntimeException(xmlResource + " could not be found");
        } 
        DOMParser domParser = new DOMParser();
        try { 
            domParser.parse(new InputSource(inputStream));
            return SUCCESS_MESSAGE;
        } catch (Exception e) {
            throw new RuntimeException(e);
        } 
    } 
 
} 
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getCharacterStream, setCharacterStream, setPublicId, setSystemId
                MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException {
 
            try { 
                if (source instanceof StreamSource) {
                    StreamSource stream = (StreamSource) source;
                    InputSource inputStream = new InputSource(stream.getInputStream());
                    inputStream.setCharacterStream(inputStream.getCharacterStream());
                    inputStream.setPublicId(stream.getPublicId());
                    inputStream.setSystemId(source.getSystemId());
                    source = new SAXSource(saxParserFactory.provide().newSAXParser().getXMLReader(), inputStream);
                } 
 
                StreamResult sr = new StreamResult(entityStream);
                transformerFactory.provide().newTransformer().transform(source, sr);
 
            } catch (SAXException ex) {
                throw new InternalServerErrorException(ex);
            } catch (ParserConfigurationException ex) {
                throw new InternalServerErrorException(ex);
            } catch (TransformerException ex) {
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        } 
 
        URL hyphenationPatternsFile = env.resolveConfig(hyphenationPatternsPath);
 
        try { 
            hyphenationTree = HyphenationCompoundWordTokenFilter.getHyphenationTree(new InputSource(hyphenationPatternsFile.toExternalForm()));
        } catch (Exception e) {
            throw new ElasticSearchIllegalArgumentException("Exception while reading hyphenation_patterns_path: " + e.getMessage());
        } 
    } 
 
    @Override 
    public TokenStream create(TokenStream tokenStream) {
        return new HyphenationCompoundWordTokenFilter(version, tokenStream,
                hyphenationTree, wordList,
                minWordSize, minSubwordSize, maxSubwordSize, onlyLongestMatch); 
    } 
} 
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
import org.xml.sax.SAXException; 
 
public class NoOpEntityResolver implements EntityResolver { 
 
    public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { 
        return new InputSource(new StringReader("")); 
    } 
 
} 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        } 
    } 
 
    private void parse(final InputStream inputStream) throws IOException, SAXException {
        DOMParser domParser = new DOMParser();
        domParser.parse(new InputSource(inputStream));
    } 
 
 
} 
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    try { 
      XMLReader xr = XMLReaderFactory.createXMLReader();
      xr.setContentHandler(this);
      xr.setErrorHandler(this);
      xr.setDTDHandler(null);
      xr.parse(new InputSource(fileReader));
      visitor.close(null);
    } catch (SAXParseException e) {
      System.out.println("XML parsing error: " + "\n" +
          "Line:    " + e.getLineNumber() + "\n" +
          "URI:     " + e.getSystemId() + "\n" +
          "Message: " + e.getMessage());        
      visitor.close(e);
      throw new IOException(e.toString());
    } catch (SAXException e) {
      visitor.close(e);
      throw new IOException(e.toString());
    } catch (RuntimeException e) {
      visitor.close(e);
      throw e;
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 
	private Document parseXmlString(String xml) throws Exception  {
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		factory.setNamespaceAware(true);
		DocumentBuilder documentBuilder = factory.newDocumentBuilder();
		InputSource inputSource = new InputSource(new StringReader(xml));
		return documentBuilder.parse(inputSource);
	} 
 
	/** 
	 * Parse the content as {@link DOMSource} and apply a {@link Matcher}. 
	 * @see <a href="http://code.google.com/p/xml-matchers/">xml-matchers</a> 
	 */ 
	public void assertSource(String content, Matcher<? super Source> matcher) throws Exception {
		Document document = parseXmlString(content);
		assertThat("Body content", new DOMSource(document), matcher);
	} 
 
	/** 
	 * Parse the expected and actual content strings as XML and assert that the 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 
			final XMLReader xr = sp.getXMLReader();
			final TexturePackParser texturePackParser = new TexturePackParser(this.mAssetManager, pAssetBasePath, this.mTextureManager);
			xr.setContentHandler(texturePackParser);
 
			xr.parse(new InputSource(new BufferedInputStream(pInputStream)));
 
			return texturePackParser.getTexturePack();
		} catch (final SAXException e) {
			throw new TexturePackParseException(e);
		} catch (final ParserConfigurationException pe) {
			/* Doesn't happen. */ 
			return null; 
		} catch (final IOException e) {
			throw new TexturePackParseException(e);
		} finally { 
			StreamUtils.close(pInputStream);
		} 
	} 
 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getByteStream, getCharacterStream, getEncoding, getPublicId, getSystemId
 
    public void testInputSourceInputStream() { 
        ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
 
        // Ordinary case 
        InputSource i = new InputSource(bais);
 
        assertEquals(bais, i.getByteStream());
        assertNull(i.getCharacterStream());
        assertNull(i.getEncoding());
        assertNull(i.getPublicId());
        assertNull(i.getSystemId());
 
        // No input stream 
        i = new InputSource((InputStream)null);
 
        assertNull(i.getByteStream());
        assertNull(i.getCharacterStream());
        assertNull(i.getEncoding());
        assertNull(i.getPublicId());
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
	} 
 
	@Test
	public void unmarshalDomSource() throws Exception {
		DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
		Document document = builder.parse(new InputSource(new StringReader(INPUT_STRING)));
		DOMSource source = new DOMSource(document);
		Object flight = unmarshaller.unmarshal(source);
		testFlight(flight); 
	} 
 
	@Test
	public void unmarshalStaxSourceXmlStreamReader() throws Exception {
		XMLInputFactory inputFactory = XMLInputFactory.newInstance();
		XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(INPUT_STRING));
		Source source = StaxUtils.createStaxSource(streamReader);
		Object flights = unmarshaller.unmarshal(source);
		testFlight(flights); 
	} 
 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Java 8 InputSource Questions & Answers:

Other Java 8 InputSource Examples

5:				DocumentBuilder db = dbf.newDocumentBuilder();
6:	
7:				InputSource is = new InputSource();
8:			        is.setCharacterStream(new StringReader(xml));
9:			        doc = db.parse(is); 
-
5:				DocumentBuilder db = dbf.newDocumentBuilder();
6:	
7:				InputSource is = new InputSource();
8:			        is.setCharacterStream(new StringReader(xml));
9:			        doc = db.parse(is);

Read More

68:	
69:				InputSource is = new InputSource();
70:			        is.setCharacterStream(new StringReader(xml));
71:			        doc = db.parse(is); 
72:	
-
68:	
69:				InputSource is = new InputSource();
70:			        is.setCharacterStream(new StringReader(xml));
71:			        doc = db.parse(is); 
72:

Read More

68:	
69:				InputSource is = new InputSource();
70:			        is.setCharacterStream(new StringReader(xml));
71:			        doc = db.parse(is); 
72:	
-
68:	
69:				InputSource is = new InputSource();
70:			        is.setCharacterStream(new StringReader(xml));
71:			        doc = db.parse(is); 
72:

Read More

See Code Examples for Java 8 InputSource Methods: