Keep track and save objects variables

Hello! i try to keeping track and save the objects values in a file and next read the changes.

If i`ve only one object a printWriter works fine, becouse i read the changes over time. but with and array of differents objects, i dont kwow exactly which is the best approach to keep track every object and his respective value. im using json to save the status but its static. i need a system to read dynamic data.

i think about making one printWriter per object, but it will be very difficult next to load all this files.

anybody enligthme.

here`s an stupid sketch to work it.


ArrayList<Obj>o = new ArrayList<Obj>();

void setup() {
  // Open the file from the createWriter() example
  size(500, 500);
  o.add(new Obj(random(width)));
  o.add(new Obj(random(width)));
}

void draw() {
  background(150);
  for (Obj obj : o) {
    obj.display();
  }
} 


class Obj {

  float x;
  float y = height/2;

  float r;

  Obj(float _x) {
    x = _x;
  }

  void display() {
    ellipse(x, y*sin(r), 10, 10);
    r+=0.01;
  }
}

i made this sketch, using XML

ArrayList<Obj>o = new ArrayList<Obj>();
XML xml;
float _x;
float _y;

void setup() {
  size(500, 500);
  o.add(new Obj(random(width), random(height)));
  o.add(new Obj(random(width), random(height)));

  xml = new XML("obj");
}


void draw() {

  background(0);
  for (Obj ob : o) {
    ob.display();
  }
  xml = loadXML("data.xml");
  loadData();

  //for (int i = 0; i < o.size(); i++) {
  //  Obj obj = o.get(i);
  //  XML bubble = xml.addChild("bubble" + i);
  //  XML position = bubble.addChild("position");
  //  // Here we can set attributes as integers directly
  //  position.setFloat("x", obj.x);
  //  position.setFloat("y", obj.y);
  //}
  //saveXML(xml, "data/data.xml");
}

void mousePressed() {
  //loadData();
}

void loadData() {
  
  for (int i = 0; i < o.size(); i++) {
    XML[] children = xml.getChildren("bubble" + i);
    XML positionElement = children[i].getChild("position");
    float x = positionElement.getFloat("x");
    float y = positionElement.getFloat("y");
    Obj e = o.get(i);
    e.x = x;
    e.y = y;
    //e.display();
    println(x);
  }
}


class Obj {

  float x;
  float y;
  float r;


  Obj(float _x, float _y) {
    x = _x;
    y = _y;
  }

  void display() {
    //r+=0.01;
    //x+=sin(r);
    ellipse(x, y, 10, 10);
  }
}

it generates this xml FIle:

<?xml version="1.0" encoding="UTF-8"?>
<obj>
  <bubble0>
    <position x="21.807062" y="96.120895"/>
  </bubble0>
  <bubble1>
    <position x="409.21637" y="63.337654"/>
  </bubble1>
  <bubble0>
    <position x="21.82706" y="96.120895"/>
  </bubble0>
  <bubble1>
    <position x="409.23636" y="63.337654"/>
  </bubble1>
  <bubble0>
    <position x="21.857056" y="96.120895"/>
  </bubble0>
  <bubble1>
    <position x="409.26636" y="63.337654"/>
  </bubble1>
  <bubble0>
    <position x="21.897045" y="96.120895"/>
  </bubble0>
</obj>

as you can see the x and y variables are changing. but i cant makes that reads over time. any ideas?