I want to put a file to FTP address automatically in a scheduler.
I have a JSON object so I can create an XML from this.
I can create a xmlString
with a code below.
I want to put the XML in the xmlString
to a file abc.xml
at an FTP address. How I can do it?
private static String objToXml(Object object) throws JAXBException {
JAXBContext context = JAXBContext.newInstance(object.getClass());
Marshaller marshallerObj = context.createMarshaller();
marshallerObj.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
StringWriter sw = new StringWriter();
marshallerObj.marshal(object, sw);
return sw.toString();
}
String xmlString = "";
try {
xmlString = objToXml(anObject);
} catch (JAXBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}