List of usage examples for java.io StringReader StringReader
public StringReader(String s)
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(xmlRecords)); Document doc = factory.newDocumentBuilder().parse(is); CDATASection cdataNode = doc.createCDATASection(""); CharacterData cdata = cdataNode; cdata.appendData("from java2s.com"); System.out.println(cdataNode); cdata.replaceData(1, 2, "new"); System.out.println(cdataNode); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(xmlRecords)); Document doc = factory.newDocumentBuilder().parse(is); CDATASection cdataNode = doc.createCDATASection(""); CharacterData cdata = cdataNode; int offset = 0; cdata.insertData(offset, "a "); cdata.appendData(" b"); System.out.println(cdataNode); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document doc = factory.newDocumentBuilder().parse(new InputSource(new StringReader(getXMLData()))); Element root = doc.getDocumentElement(); System.out.println(root);/*from ww w .ja va 2 s. com*/ }
From source file:Main.java
public static void main(String[] args) throws IOException { String fileContent = "s1=1\n" + "s2=Main\n" + "s3=Fri Jan 31 00:00:00 IST 3913"; StringReader reader = new StringReader(fileContent); PropertyResourceBundle bundle = new Main(reader); Set keySet = bundle.handleKeySet(); Iterator keys = keySet.iterator(); while (keys.hasNext()) { System.out.println("Bundle key: " + keys.next()); }/*from www .j ava2s.c o m*/ }
From source file:Main.java
public static void main(String[] args) throws Exception { String xmlString = "<message>HELLO!</message> "; JAXBContext jc = JAXBContext.newInstance(String.class); Unmarshaller unmarshaller = jc.createUnmarshaller(); StreamSource xmlSource = new StreamSource(new StringReader(xmlString)); JAXBElement<String> je = unmarshaller.unmarshal(xmlSource, String.class); System.out.println(je.getValue()); }
From source file:Main.java
public static void main(String[] args) throws Exception { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader("<a></a>")); reader = inputFactory.createFilteredReader(reader, new ElementOnlyFilter()); System.out.println(reader.getEventType()); }
From source file:Main.java
License:asdf
public static void main(String args[]) throws Exception { DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); // Create the parser Document xmlDoc = builder.parse(new InputSource(new StringReader(xmlString))); xmlDoc.setXmlVersion("2.0"); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document doc = factory.newDocumentBuilder().parse(new InputSource(new StringReader(getXMLData()))); visit(doc, 0);/* ww w.j a va 2s . co m*/ }
From source file:Main.java
public static void main(String[] args) throws Exception { XPathFactory xpf = XPathFactory.newInstance(); XPath xPath = xpf.newXPath(); InputSource inputSource = new InputSource(new StringReader(XML)); String result = (String) xPath.evaluate("//gender", inputSource, XPathConstants.STRING); System.out.println(result);/*from w ww . j ava 2 s . co m*/ }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document doc = factory.newDocumentBuilder().parse(new InputSource(new StringReader(getXMLData()))); Element root = doc.getDocumentElement(); EntityReference eref = (EntityReference) root.getFirstChild(); }