Example usage for java.io ObjectOutput writeObject

List of usage examples for java.io ObjectOutput writeObject

Introduction

In this page you can find the example usage for java.io ObjectOutput writeObject.

Prototype

public void writeObject(Object obj) throws IOException;

Source Link

Document

Write an object to the underlying storage or stream.

Usage

From source file:org.apache.ibatis.executor.loader.AbstractSerialStateHolder.java

@Override
public final void writeExternal(final ObjectOutput out) throws IOException {
    boolean firstRound = false;
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream os = stream.get();
    if (os == null) {
        os = new ObjectOutputStream(baos);
        firstRound = true;/*from   w  w  w  . j  a v a  2 s.  c o  m*/
        stream.set(os);
    }

    os.writeObject(this.userBean);
    os.writeObject(this.unloadedProperties);
    os.writeObject(this.objectFactory);
    os.writeObject(this.constructorArgTypes);
    os.writeObject(this.constructorArgs);

    final byte[] bytes = baos.toByteArray();
    out.writeObject(bytes);

    if (firstRound) {
        stream.remove();
    }
}

From source file:xbird.xquery.expr.path.PathExpr.java

public void writeExternal(ObjectOutput out) throws IOException {
    final List<XQExpression> steps = _steps;
    final int numSteps = steps.size();
    out.writeInt(numSteps);//from ww  w .  j  a  v a  2s. c o m
    for (int i = 0; i < numSteps; i++) {
        XQExpression step = steps.get(i);
        out.writeObject(step);
    }
    final XQExpression analyzed = _analyzedExpr;
    if (analyzed == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        out.writeObject(analyzed);
    }
}

From source file:cybervillains.ca.KeyStoreManager.java

private synchronized void persistKeyPairMap() {
    try {/*from   w ww . ja  va2 s.  c o  m*/
        ObjectOutput out = new ObjectOutputStream(new FileOutputStream(new File(root, KEYMAP_SER_FILE)));
        out.writeObject(_rememberedPrivateKeys);
        out.flush();
        out.close();
    } catch (FileNotFoundException e) {
        // writing, won't happen.
        e.printStackTrace();
    } catch (IOException e) {
        // very bad
        e.printStackTrace();
        throw new Error(e);
    }
}

From source file:cybervillains.ca.KeyStoreManager.java

private synchronized void persistCertMap() {
    try {// w  w w.  ja  v  a  2s  .c  om
        ObjectOutput out = new ObjectOutputStream(new FileOutputStream(new File(root, CERTMAP_SER_FILE)));
        out.writeObject(_certMap);
        out.flush();
        out.close();
    } catch (FileNotFoundException e) {
        // writing, this shouldn't happen...
        e.printStackTrace();
    } catch (IOException e) {
        // big problem!
        e.printStackTrace();
        throw new Error(e);
    }
}

From source file:cybervillains.ca.KeyStoreManager.java

private synchronized void persistSubjectMap() {
    try {/* w ww. java  2 s .co m*/
        ObjectOutput out = new ObjectOutputStream(new FileOutputStream(new File(root, SUBJMAP_SER_FILE)));
        out.writeObject(_subjectMap);
        out.flush();
        out.close();
    } catch (FileNotFoundException e) {
        // writing, this shouldn't happen...
        e.printStackTrace();
    } catch (IOException e) {
        // big problem!
        e.printStackTrace();
        throw new Error(e);
    }
}

From source file:cybervillains.ca.KeyStoreManager.java

private synchronized void persistPublicKeyMap() {
    try {/*from  w w  w  .j  av  a 2  s. c  om*/
        ObjectOutput out = new ObjectOutputStream(new FileOutputStream(new File(root, PUB_KEYMAP_SER_FILE)));
        out.writeObject(_mappedPublicKeys);
        out.flush();
        out.close();
    } catch (FileNotFoundException e) {
        // writing, won't happen
        e.printStackTrace();
    } catch (IOException e) {
        // very bad
        e.printStackTrace();
        throw new Error(e);
    }
}

From source file:BeanContainer.java

public void writeExternal(ObjectOutput out) throws IOException {
        out.writeBoolean(m_digital);/*from   www.jav a  2s . co  m*/
        out.writeObject(getBackground());
        out.writeObject(getForeground());
        out.writeObject(getPreferredSize());
    }

From source file:com.openbravo.pos.ticket.TicketInfo.java

@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeObject(m_sId);
    out.writeInt(tickettype);//from w  ww  .  jav  a  2  s. c  o m
    out.writeInt(m_iTicketId);
    out.writeObject(m_Customer);
    out.writeObject(m_dDate);
    out.writeObject(attributes);
    out.writeObject(m_aLines);

    out.writeInt(ticketstatus);
}

From source file:gov.nij.er.ui.EntityResolutionDemo.java

private void saveParameters(File file) {
    if (file.exists()) {
        int option = promptParametersFileOverwrite();
        if (option == JOptionPane.NO_OPTION || option == JOptionPane.CLOSED_OPTION
                || option == JOptionPane.CANCEL_OPTION) {
            return;
        }/*from w w w . jav a 2s  .  com*/
    }
    File enhancedFile = file;
    if (!file.getName().contains(SINGLE_DOT)) {
        enhancedFile = new File(file.getAbsolutePath() + SINGLE_DOT + PARAMETER_FILE_EXTENSION);
    }
    ObjectOutput output = null;
    try {
        output = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(enhancedFile)));
        output.writeObject(parametersTableModel.getAttributeParameters());
        LOG.debug("Wrote parameters to file " + enhancedFile.getAbsolutePath());
    } catch (IOException ex) {
        error("Error writing parameters to a file.");
        ex.printStackTrace();
    } finally {
        try {
            output.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:gridool.db.DBInsertOperation.java

@Override
public void writeExternal(ObjectOutput out) throws IOException {
    super.writeExternal(out);
    IOUtils.writeString(createTableDDL, out);
    IOUtils.writeString(tableName, out);
    final String[] fn = fieldNames;
    final int numFields = (fn == null) ? 0 : fn.length;
    out.writeInt(numFields);//from  w  w w  .  j  a  va2 s .c  o m
    for (int i = 0; i < numFields; i++) {
        IOUtils.writeString(fn[i], out);
    }
    final DBRecord[] r = records;
    final int numRecords = r.length;
    out.writeInt(numRecords);
    for (int i = 0; i < numRecords; i++) {
        out.writeObject(r[i]);
    }
}