Exemple #1
0
  /** Load a object of type 'clazz' from a file. */
  public <T> T load(Class<T> clazz, InputStream is) throws JAXBException {
    Context context;
    T object;

    context = getContext(clazz);
    synchronized (context) {
      object = (T) context.unmarshal(is);
      return object;
    }
  }
Exemple #2
0
  /** Save a object to a outputstream. */
  private void save(Object object, OutputStream os) throws JAXBException, IOException {
    Writer writer;
    Context context;

    writer = new OutputStreamWriter(os);

    context = getContext(object.getClass());
    synchronized (context) {
      context.marshal(object, writer);
    }
  }