Skip to content

Commit

Permalink
update jar
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaslprr committed Jun 2, 2021
1 parent 35960f4 commit ed0d55d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
39 changes: 39 additions & 0 deletions src/converter/XmlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,45 @@ public static String xmlStringToSwaggerJson(String xml) {
}
}

public static Global xmlFileToJavaClass(File file) {
try {

JAXBContext jaxbContext = JAXBContext.newInstance(Global.class);

Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

Global global = (Global) unmarshaller.unmarshal(file);

return global;


} catch (Exception e) {
e.printStackTrace();
return null;
}
}



public static Global xmlStringToJavaClass(String xml) {
try {

JAXBContext jaxbContext = JAXBContext.newInstance(Global.class);

Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

InputStream stream = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8));

Global global = (Global) unmarshaller.unmarshal(stream);

return global;


} catch (Exception e) {
e.printStackTrace();
return null;
}
}


}
4 changes: 0 additions & 4 deletions src/test/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

import java.io.File;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;

import converter.XmlParser;
import global.Global;

public class Main {

Expand Down
Binary file modified xml2swagger.jar
Binary file not shown.

0 comments on commit ed0d55d

Please sign in to comment.