Example usage for java.io ObjectOutputStream writeUTF

List of usage examples for java.io ObjectOutputStream writeUTF

Introduction

In this page you can find the example usage for java.io ObjectOutputStream writeUTF.

Prototype

public void writeUTF(String str) throws IOException 

Source Link

Document

Primitive data write of this String in modified UTF-8 format.

Usage

From source file:org.taverna.server.master.worker.RemoteRunDelegate.java

private void writeObject(ObjectOutputStream out) throws IOException {
    out.defaultWriteObject();/* www. j a  v  a  2  s.  c  om*/
    out.writeUTF(secContext.getOwner().getName());
    out.writeObject(secContext.getFactory());
    out.writeObject(new MarshalledObject<>(run));
}

From source file:pt.webdetails.cpk.elements.impl.KettleResult.java

private void writeObject(java.io.ObjectOutputStream out) throws IOException {
    out.defaultWriteObject();/*from   ww  w .  j  ava  2s. c  o  m*/

    String resultXmlString = this.result.getXML();
    out.writeUTF(resultXmlString);
}

From source file:tvbrowser.core.Settings.java

/**
 * Stores the window settings for this plugin
 *///from www  . jav a  2 s.c o  m
private static void storeWindowSettings() {
    File windowSettingsFile = new File(Settings.getUserSettingsDirName(), WINDOW_SETTINGS_FILE);
    StreamUtilities.objectOutputStreamIgnoringExceptions(windowSettingsFile, new ObjectOutputStreamProcessor() {
        public void process(ObjectOutputStream out) throws IOException {
            out.writeInt(1); // write version

            out.writeInt(mWindowSettings.size());

            for (String key : mWindowSettings.keySet()) {
                WindowSetting setting = mWindowSettings.get(key);

                if (setting != null) {
                    out.writeUTF(key);
                    mWindowSettings.get(key).saveSettings(out);
                }
            }

            out.close();
        }
    });
}

From source file:uk.ac.ebi.fg.jobs.JobController.java

/**
 * Retrieves ontology distance calculator object from file or creates new object in case EFO version or
 * ontology distance is different to file
 *
 * @param efo                 currently used EFO
 * @param maxOntologyDistance maximal ontology distance for ontology term distance calculations
 * @param fileLocation//from  www . ja va  2  s . c  om
 * @return
 * @throws Exception
 */
private OntologyDistanceCalculator getOntologyDistanceCalculator(IEFO efo, int maxOntologyDistance,
        String fileLocation) throws Exception {
    String version = efo.getVersionInfo();
    OntologyDistanceCalculator distCalc = null;

    File ontDistFile = new File(fileLocation);

    if (ontDistFile.exists()) {
        FileInputStream fis = new FileInputStream(ontDistFile);
        ObjectInputStream ois = new ObjectInputStream(fis);

        if ((ois.readInt() == maxOntologyDistance) && (ois.readUTF().equals(version))) {
            logger.info("Precalculated ontology distance file found for version " + version + " and distance "
                    + maxOntologyDistance);

            distCalc = (OntologyDistanceCalculator) ois.readObject();

            logger.info("\'ontology distance calculator\' object retrieved from file");
        }
        ois.close();
    }
    if (null == distCalc) {
        logger.info("Matching precalculated ontology distance file not found.");
        distCalc = new OntologyDistanceCalculator(efo, maxOntologyDistance);

        logger.info("Creating file " + ontDistFile);
        FileOutputStream fos = new FileOutputStream(ontDistFile);
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeInt(maxOntologyDistance);
        oos.writeUTF(version);
        oos.writeObject(distCalc);

        oos.close();
        logger.info("File " + ontDistFile + " successfully created");
    }

    return distCalc;
}