Examples of ObjectInputStream


Examples of java.io.ObjectInputStream

            // try and grab the header
            tempHeader = (Instances) v.elementAt(1);
          }
        } /* binary */ else {

          ObjectInputStream is =
            new ObjectInputStream(new BufferedInputStream(
                                                          new FileInputStream(loadFrom)));
          // try and read the model
          temp = (weka.classifiers.Classifier)is.readObject();
          // try and read the header (if present)
          try {
            tempHeader = (Instances)is.readObject();
          } catch (Exception ex) {
            //            System.err.println("No header...");
            // quietly ignore
          }
          is.close();
        }       

        // Update name and icon
        setTrainedClassifier(temp);
        // restore header
View Full Code Here

Examples of java.io.ObjectInputStream

  private static GlobalPluginProgramFormatingManager mInstance;
  private GlobalPluginProgramFormating[] mAvailableProgramConfigurations;
 
  private GlobalPluginProgramFormatingManager() {
    mInstance = this;
    ObjectInputStream in=null;
   
    try {
      File programConfigFile = new File(Settings.getUserSettingsDirName(),"programConfigurations.dat");
     
      in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(programConfigFile), 0x1000));
     
      in.readInt(); // read version
     
      mAvailableProgramConfigurations = new GlobalPluginProgramFormating[in.readInt()];
     
      for(int i = 0; i < mAvailableProgramConfigurations.length; i++) {
        mAvailableProgramConfigurations[i] = GlobalPluginProgramFormating.load(in);
      }
     
    }catch(Exception e) {
      mAvailableProgramConfigurations = new GlobalPluginProgramFormating[2];
      mAvailableProgramConfigurations[0] = getDefaultConfiguration();
      new Thread("Plugin formating creation") {
        public void run() {
          try {
            Thread.sleep(100);
          } catch (InterruptedException e) {}
         
          mAvailableProgramConfigurations[1] = getTvPearlFormating();
          store();
        }
      }.start();
    } finally {
      if (in!=null) {
        try { in.close(); } catch(IOException exc) {}
      }
    }
  }
View Full Code Here

Examples of java.io.ObjectInputStream

    byte opt = buf[pos++];

    if (opt != Message.NULL) {
      // Reads notification object
      ObjectInputStream ois = null;
      if (compressedFlows) {
        readFully(4);
        int length = readInt();
       
        if (getLogger().isLoggable(BasicLevel.DEBUG))
          getLogger().log(BasicLevel.DEBUG, "readMessage - length=" + length);
       
        byte[] buf = new byte[length];
        int n = 0;
        do {
          int count = read(buf, n, length - n);
          if (count < 0) throw new EOFException();
          n += count;
        } while (n < length);
        ois = new ObjectInputStream(new GZIPInputStream(new ByteArrayInputStream(buf)));
      } else {
        ois = new ObjectInputStream(this);
      }
     
      if (getLogger().isLoggable(BasicLevel.DEBUG))
        getLogger().log(BasicLevel.DEBUG, "readMessage - 2");

      msg.not = (Notification) ois.readObject();
     
      if (getLogger().isLoggable(BasicLevel.DEBUG))
        getLogger().log(BasicLevel.DEBUG, "readMessage - 3");
     
      if (msg.not.expiration > 0)
View Full Code Here

Examples of java.io.ObjectInputStream

  public void react(AgentId from, Notification not) throws Exception {
    if (not instanceof AgentCreateRequest) {
      AgentCreateRequest cnot = (AgentCreateRequest) not;
      try {
        // Restore the new agent state.
        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(cnot.agentState, 0,
            cnot.agentState.length));
        Agent ag = (Agent) ois.readObject();
        try {
          ois.close();
        } catch (IOException exc) {}

        // Initializes and creates the agent
        // TODO: (ThreadEngine) Thread.currentThread() ...
        AgentServer.engine.createAgent(cnot.deploy, ag);
View Full Code Here

Examples of java.io.ObjectInputStream

      }
     
      FileInputStream fis = null;
      try {
        fis = new FileInputStream(cfgFile);
        ObjectInputStream ois = new ObjectInputStream(fis);
        a3config = (A3CMLConfig) ois.readObject();
      } catch (Exception exc) {
        Log.logger.log(BasicLevel.WARN, "Can't load configuration: " + path, exc);
      } finally {
        if (fis != null) fis.close();
      }

      if (Log.logger.isLoggable(BasicLevel.DEBUG))
        Log.logger.log(BasicLevel.DEBUG,
                       "Config.load : a3cmlconfig = " + a3config);
      return a3config;
    }

    //search a3config in path used to load classes.
    ClassLoader classLoader = null;
    InputStream is = null;
    try {
      classLoader = A3CMLConfig.class.getClassLoader();
      if (classLoader != null) {
        Log.logger.log(BasicLevel.WARN,
                       "Trying to find [" + path + "] using " +
                       classLoader + " class loader.");
        is = classLoader.getResourceAsStream(path);
      }
    } catch(Throwable t) {
      Log.logger.log(BasicLevel.WARN,
                     "Can't find [" + path + "] using " +
                     classLoader + " class loader.", t);
      is = null;
    }
    if (is == null) {
      // Last ditch attempt: get the resource from the system class path.
      Log.logger.log(BasicLevel.WARN,
                     "Trying to find serialized config using ClassLoader.getSystemResource().");
      is = ClassLoader.getSystemResourceAsStream(path);
    }
    if (is != null) {
      ObjectInputStream ois = new ObjectInputStream(is);
      a3config = (A3CMLConfig) ois.readObject();
    }

    if (a3config == null) {
      Log.logger.log(BasicLevel.WARN,
                     "Unable to find configuration file: " + path);
View Full Code Here

Examples of java.io.ObjectInputStream

   */
  public final Object load(String dirName, String name) throws IOException, ClassNotFoundException {
    byte[] buf = loadByteArray(dirName, name);
    if (buf != null) {
      ByteArrayInputStream bis = new ByteArrayInputStream(buf);
      ObjectInputStream ois = new ObjectInputStream(bis);
      try {
        return ois.readObject();
      } finally {
        ois.close();
        bis.close();
      }
    }
   
    return null;
View Full Code Here

Examples of java.io.ObjectInputStream

 
  public final Object load(String dirName, String name) throws IOException, ClassNotFoundException {
    byte[] buf = loadByteArray(dirName, name);
    if (buf != null) {
      ByteArrayInputStream bis = new ByteArrayInputStream(buf);
      ObjectInputStream ois = new ObjectInputStream(bis);
      try {
        return ois.readObject();
      } finally {
        ois.close();
        bis.close();
      }
    }
   
    return null;
View Full Code Here

Examples of java.io.ObjectInputStream

    }
  } else {
  if (selected.getName().endsWith(".gz")) {
    is = new GZIPInputStream(is);
  }
  ObjectInputStream objectInputStream = new ObjectInputStream(is);
  classifier = (Classifier) objectInputStream.readObject();
  try { // see if we can load the header
    trainHeader = (Instances) objectInputStream.readObject();
  } catch (Exception e) {} // don't fuss if we can't
  objectInputStream.close();
  }
      } catch (Exception e) {
 
  JOptionPane.showMessageDialog(null, e, "Load Failed",
              JOptionPane.ERROR_MESSAGE);
View Full Code Here

Examples of java.io.ObjectInputStream

        final int len = s.readInt();
        final byte[] b = new byte[len];
        s.readFully(b, 0, len);

        FastByteArrayInputStream bis = new FastByteArrayInputStream(b);
        ObjectInputStream ois = new ObjectInputStream(bis);
        this._bodyExpr = (XQExpression) ois.readObject();
        this._bindingVar = (BindingVariable) ois.readObject();

        this._exprBytes = b;
    }
View Full Code Here

Examples of java.io.ObjectInputStream

        out.close();

        final byte[] b = f.toByteArray();

        FastByteArrayInputStream in = new FastByteArrayInputStream(b);
        ObjectInputStream oin = new ObjectInputStream(in);

        Assert.assertEquals(student1, oin.readObject());
        Assert.assertEquals(5, oin.readInt());
        Assert.assertEquals(student2, oin.readObject());

        oin.close();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.