在FTP服务器上创建XML文件,而无需创建物理文件localy

时间:2015-08-20 08:39:32

标签: java xml ftp jaxb

所以我想在FTP服务器上创建XML文件。我知道,我可以在当地进行,稍后只需上传它,但我想在没有本地物理文件的情况下制作它。

我在本地创建它的代码是:

public class XMLFileMaker {
    public void countryObjectsToXML(Employee emp, String path) throws JAXBException {
        JAXBContext context = JAXBContext.newInstance(Employee.class);
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        marshaller.setProperty("com.sun.xml.bind.xmlDeclaration", Boolean.FALSE);
        marshaller.setProperty("com.sun.xml.bind.xmlHeaders", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        marshaller.marshal(emp, new File(path + File.separator + "Informations.xml"));
    }
}

有人有任何想法如何解决我的问题?

(上传CSV文件我喜欢这里:Uploading a csv file to ftp without creating a physical file locally 但现在我不知道如何上传XML:/)

1 个答案:

答案 0 :(得分:0)

FTP是一种文件传输协议,您可以在服务器上移动文件但不支持文件创建。对于所有可用的命令类型&#34; help&#34; ftp登录后。

相关问题