1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| public static void transformerXml(Document document, String fichier) {
try {
// Création de la source DOM
Source source = new DOMSource(document);
// Création du fichier de sortie
URL url = new URL("ftp://login:pass@ftpperso.free.fr/fichier.extension");
URLConnection urlConnection = url.openConnection();
Result resultat = new StreamResult(urlConnection.getOutputStream());
// Configuration du transformer
TransformerFactory fabrique = TransformerFactory.newInstance();
Transformer transformer = fabrique.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
// Transformation
transformer.transform(source, resultat);
}catch(Exception e){
e.printStackTrace();
}
} |