title: ODT File to Byte Array Java
body: <p>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 :<a href="https://stackoverflow.com/questions/32201313/how-can-i-generate-byte-array-from-an-odt-file-java">How can I generate Byte array from an ODT file java</a> .</p>
  
  <p>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?</p>
  
  <p>Tried this to Adress this File:</p>
  
  <pre><code>            //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);
  </code></pre>
  
  <p>But this does not seem to work.</p>
  
  <p>So maybe you can tell me how I can Adress the File :)</p>