Niagara Ax : Copy a BComponent to a bog file. 3

In Niagara Ax, a bog file is nothing but a zipped xml. Whenever we need to serialize a BComponent as a file in the station files structure, we can use the below code to achieve the same.

 Copy a BComponent to a bogFile
 @param comp : The source component
 @param bogFile : The bogfile to be persisted to.
 public static void copyComponentToBog(BComponent comp,BIFile bogFile) throws IOException {
      BogEncoder bogencoder = new  BogEncoder(bogFile.getOutputStream());

Vice-verse, to decode or convert a bog file to a component you can use BodDecoder class as shown below.

     * Decode a bog file and return its BComponent object.
     * @param sourceFile : The source bog file
     * @return BComponent
     * @throws Exception
    public static BComponent bogFileToComponent(BIFile sourceFile throws Exception {
      BogDecoder bogDec = null;
          BogDecoder bogDec = new BogDecoder(file);
          BComponent component = ((BComponent)(bogDec.decodeDocument()));

          if(null != bogDec){
      return component;

Disclaimer: Niagara Ax tips in this website are sourced from the Open Niagara Ax online community . A forum where you can ask and resolve Niagara framework related queries.

3 thoughts on “Niagara Ax : Copy a BComponent to a bog file.

  1. Reply Fernando Flores Dec 8,2017 7:24 am

    Paul, I have .bog file that I need to use to create a new station. Is there a process? Thank you!

  2. Reply Abhishek Feb 3,2016 6:31 pm

    Hi Ajo,
    Hope You will be doing great. This is Abhishek here.
    Need one help from you…I was trying to convert the config.bog file to .mdb file. Could you plz help me out on this.

    • Reply Ajo Paul Feb 17,2016 4:33 am


      I suppose you are trying this from Java, you can use libraries to create the mdb file. Strip the config.bog which is nothing but a archive file which contains a XML that lists all the station components used. Loop through the components and assuming you have a schema for your Access db perform the inserts or updates as necessary.

Leave a Reply