List of usage examples for org.jdom2.output XMLOutputter XMLOutputter
public XMLOutputter(XMLOutputProcessor processor)
XMLOutputter
with the specified XMLOutputProcessor. From source file:model.data.RendezVousIp.java
License:Open Source License
@Override protected void putValues() { XMLOutputter out = new XMLOutputter(Format.getPrettyFormat()); addValue("ips", out.outputString(ips)); }
From source file:Model.ServidorXMLFIle.java
public static boolean saveUserInServerDataBase(String Hora, String Nombre, String Cantidad, String Protocolo) { Document doc;/* w w w . j a v a 2s . co m*/ Element root, newChild; SAXBuilder builder = new SAXBuilder(); try { doc = builder.build(UtilCliente.USERS_XML_PATH); root = doc.getRootElement(); newChild = new Element(UtilCliente.SERVER_TAG); newChild.setAttribute(UtilCliente.HORA_TAG, Hora); newChild.setAttribute(UtilCliente.NOMBRE_TAG, Nombre); newChild.setAttribute(UtilCliente.CANTIDAD_TAG, Cantidad); newChild.setAttribute(UtilCliente.PRIMITIVA_TAG, Protocolo); root.addContent(newChild); try { Format format = Format.getPrettyFormat(); XMLOutputter out = new XMLOutputter(format); FileOutputStream file = new FileOutputStream(UtilCliente.USERS_XML_PATH); out.output(doc, file); file.flush(); file.close(); } catch (Exception e) { e.printStackTrace(); } } catch (JDOMParseException e) { System.out.println(UtilCliente.ERROR_XML_EMPTY_FILE); e.printStackTrace(); } catch (JDOMException e) { System.out.println(UtilCliente.ERROR_XML_PROCESSING_FILE); e.printStackTrace(); } catch (IOException e) { System.out.println(UtilCliente.ERROR_XML_PROCESSING_FILE); e.printStackTrace(); } return true; }
From source file:Modelo.ProductorXMLFIle.java
public static boolean saveUserInServerDataBase(String Hora, String Nombre, String Cantidad) { Document doc;//w ww . j av a 2 s .c o m Element root, newChild; SAXBuilder builder = new SAXBuilder(); try { doc = builder.build(UtilProductor.USERS_XML_PATH); root = doc.getRootElement(); newChild = new Element(UtilProductor.SERVER_TAG); newChild.setAttribute(UtilProductor.HORA_TAG, Hora); newChild.setAttribute(UtilProductor.NOMBRE_TAG, Nombre); newChild.setAttribute(UtilProductor.CANTIDAD_TAG, Cantidad); root.addContent(newChild); try { Format format = Format.getPrettyFormat(); XMLOutputter out = new XMLOutputter(format); FileOutputStream file = new FileOutputStream(UtilProductor.USERS_XML_PATH); out.output(doc, file); file.flush(); file.close(); } catch (Exception e) { e.printStackTrace(); } } catch (JDOMParseException e) { System.out.println(UtilProductor.ERROR_XML_EMPTY_FILE); e.printStackTrace(); } catch (JDOMException e) { System.out.println(UtilProductor.ERROR_XML_PROCESSING_FILE); e.printStackTrace(); } catch (IOException e) { System.out.println(UtilProductor.ERROR_XML_PROCESSING_FILE); e.printStackTrace(); } return true; }
From source file:Modelo.ServidorXMLFIle.java
public static boolean saveUserInServerDataBase(String Hora, String Nombre, String Cantidad, String Protocolo) { Document doc;//from w w w. j av a 2s . c om Element root, newChild; SAXBuilder builder = new SAXBuilder(); try { doc = builder.build(Util.USERS_XML_PATH); root = doc.getRootElement(); newChild = new Element(Util.SERVER_TAG); newChild.setAttribute(Util.HORA_TAG, Hora); newChild.setAttribute(Util.NOMBRE_TAG, Nombre); newChild.setAttribute(Util.CANTIDAD_TAG, Cantidad); newChild.setAttribute(Util.PRIMITIVA_TAG, Protocolo); root.addContent(newChild); try { Format format = Format.getPrettyFormat(); XMLOutputter out = new XMLOutputter(format); FileOutputStream file = new FileOutputStream(Util.USERS_XML_PATH); out.output(doc, file); file.flush(); file.close(); } catch (Exception e) { e.printStackTrace(); } } catch (JDOMParseException e) { System.out.println(Util.ERROR_XML_EMPTY_FILE); e.printStackTrace(); } catch (JDOMException e) { System.out.println(Util.ERROR_XML_PROCESSING_FILE); e.printStackTrace(); } catch (IOException e) { System.out.println(Util.ERROR_XML_PROCESSING_FILE); e.printStackTrace(); } return true; }
From source file:msi.gama.doc.util.UnifyDoc.java
License:Open Source License
public static void unify(boolean local) { try {//from w w w. ja v a2s .co m WorkspaceManager ws = new WorkspaceManager(".", local); HashMap<String, File> hmFiles = ws.getProductDocFiles(); Document doc = mergeFiles(hmFiles); System.out.println("" + hmFiles); XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat()); sortie.output(doc, new FileOutputStream(Constants.DOCGAMA_GLOBAL_FILE)); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:msi.gama.doc.util.UnifyDoc.java
License:Open Source License
public static void unifyAllProjects(boolean local) { try {//from w w w . ja va2s .co m WorkspaceManager ws = new WorkspaceManager(".", local); HashMap<String, File> hmFiles = local ? ws.getAllDocFilesLocal() : ws.getAllDocFiles(); Document doc = mergeFiles(hmFiles); System.out.println("" + hmFiles); XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat()); sortie.output(doc, new FileOutputStream(Constants.DOCGAMA_GLOBAL_FILE)); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:neon.common.files.XMLTranslator.java
License:Open Source License
@Override public void translate(Document document, OutputStream output) throws IOException { XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()); outputter.output(document, output);/*ww w . j a va 2 s .c om*/ }
From source file:neon.systems.files.XMLTranslator.java
License:Open Source License
public ByteArrayOutputStream translate(Document output) { ByteArrayOutputStream out = new ByteArrayOutputStream(); XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()); try {/*from w w w. ja v a 2s . c o m*/ outputter.output(output, out); } catch (IOException e) { e.printStackTrace(); } return out; }
From source file:neon.ui.dialog.OptionDialog.java
License:Open Source License
@FXML private void save() { Document doc = new Document(); try {/* ww w. ja v a2 s .c om*/ FileInputStream in = new FileInputStream("neon.ini"); doc = new SAXBuilder().build(in); in.close(); } catch (Exception e) { Engine.getLogger().severe(e.getMessage()); } Element ini = doc.getRootElement(); if (numpadButton.isSelected()) { config.setKeys(CClient.KeyboardSetting.NUMPAD); ini.getChild("keys").setText("numpad"); } else if (azertyButton.isSelected()) { config.setKeys(CClient.KeyboardSetting.AZERTY); ini.getChild("keys").setText("azerty"); } else if (qwertyButton.isSelected()) { config.setKeys(CClient.KeyboardSetting.QWERTY); ini.getChild("keys").setText("qwerty"); } else if (qwertzButton.isSelected()) { config.setKeys(CClient.KeyboardSetting.QWERTZ); ini.getChild("keys").setText("qwertz"); } XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()); try { FileOutputStream out = new FileOutputStream("neon.ini"); outputter.output(doc, out); out.close(); } catch (IOException e) { Engine.getLogger().severe(e.getMessage()); } stage.close(); }
From source file:net.FriendsUnited.Services.FileServer.java
License:Open Source License
private void sendDirectoryListing(FriendPacket pkt, String path) { log.info("Received Request for Listing of {}--{}", SharedFolder, path); File dir = new File(SharedFolder + path); File[] files = dir.listFiles(); if (null == files) { replyWithFailurePacket(pkt, "Directory " + dir.getPath() + " can not be read"); } else {/*from w ww . ja va 2 s . c om*/ Element root = new Element("FolderListing"); for (int i = 0; i < files.length; i++) { File f = files[i]; Element fe; if (true == f.isDirectory()) { fe = new Element("Directory"); fe.setText(f.getName()); } else { fe = new Element("File"); fe.setText(f.getName()); Element size = new Element("Size"); size.addContent("" + f.length()); fe.addContent(size); } Element lastModified = new Element("lastModified"); long time = f.lastModified(); lastModified.addContent("" + time); fe.addContent(lastModified); root.addContent(fe); } Document doc = new Document(root); XMLOutputter xout = new XMLOutputter(Format.getCompactFormat()); ByteArrayOutputStream bout = new ByteArrayOutputStream(); try { xout.output(doc, bout); ByteConverter bc = new ByteConverter(); bc.add(DIRECTORY_LISTING); bout.flush(); log.debug("Size of Listing XML : " + bout.size()); bc.add(bout.size()); // length of String bc.add(bout.toByteArray()); // String Data FriendPacket replyPacket = new FriendPacket(pkt.getTargetServer(), pkt.getTargetService(), // source pkt.getSourceServer(), pkt.getSourceService(), // target bc.toByteArray()); // payload log.debug("sending : " + replyPacket); server.sendPacketIntoNetwork(this, replyPacket); log.debug("Send reply with Listing !"); } catch (IOException e) { replyWithFailurePacket(pkt, Tool.fromExceptionToString(e)); } } }