I am Trying to get my odt file into a ByteArray for Uploadting it to my server. I Think i found the way how to do it here :How can I generate Byte array from an ODT file java .
But the one Problem I have is how can I use this on the File that is currently open in the Writer because I want that all this happens when I press a Button?
Tried this to Adress this File:
//Abspeichern des Documents im Temp Ordner
String storeUrl = "file:///C:/Windows/Temp/Test.odt";
XModel xDocModel = this.frame.getController().getModel();
XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xDocModel);
XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
PropertyValue[] storeProps = new PropertyValue[1];
storeProps[0] = new PropertyValue();
storeProps[0].Name = "Overwrite";
storeProps[0].Value = new Boolean(true);
try {
xStorable.storeToURL(storeUrl, storeProps);
} catch (com.sun.star.io.IOException ex) {
Logger.getLogger(OptionPageDemo.class.getName()).log(Level.SEVERE, null, ex);
}
//Konvertieren in byte[]
Path Test = Paths.get("C:/Windows/Temp/Test.odt");
byte[] data = Files.readAllBytes(Test);
But this does not seem to work.
So maybe you can tell me how I can Adress the File :)