File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change 44import java .io .File ;
55import java .io .FileWriter ;
66import java .io .IOException ;
7+ import java .io .StringReader ;
78import java .io .StringWriter ;
89
910import javax .xml .bind .JAXBContext ;
@@ -23,7 +24,14 @@ public static Mujoco unmarshal(File xml) throws JAXBException {
2324 return (Mujoco ) jaxbUnmarshaller .unmarshal (xml );
2425
2526 }
27+ public static Mujoco unmarshal (String xml ) throws JAXBException {
28+ JAXBContext jaxbContext = JAXBContext .newInstance (Mujoco .class );
29+ Unmarshaller jaxbUnmarshaller = jaxbContext .createUnmarshaller ();
2630
31+ // We had written this file in marshalling example
32+ return (Mujoco ) jaxbUnmarshaller .unmarshal (new StringReader (xml ));
33+
34+ }
2735 public static String marshal (Mujoco source ) throws JAXBException {
2836 JAXBContext jaxbContext = JAXBContext .newInstance (Mujoco .class );
2937 Marshaller jaxbMarshaller = jaxbContext .createMarshaller ();
You can’t perform that action at this time.
0 commit comments