⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serializedinstancessaver.java

📁 矩阵的QR分解算法
💻 JAVA
字号:
/* *    This program is free software; you can redistribute it and/or modify *    it under the terms of the GNU General Public License as published by *    the Free Software Foundation; either version 2 of the License, or *    (at your option) any later version. * *    This program is distributed in the hope that it will be useful, *    but WITHOUT ANY WARRANTY; without even the implied warranty of *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *    GNU General Public License for more details. * *    You should have received a copy of the GNU General Public License *    along with this program; if not, write to the Free Software *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *//* *    SerializedInstancesSaver.java *    Copyright (C) 2004 University of Waikato, Hamilton, New Zealand * */package weka.core.converters;import weka.core.Capabilities;import weka.core.Capabilities.Capability;import java.io.BufferedOutputStream;import java.io.FileOutputStream;import java.io.IOException;import java.io.ObjectOutputStream;/** <!-- globalinfo-start --> * Serializes the instances to a file with extension bsi. * <p/> <!-- globalinfo-end --> * <!-- options-start --> * Valid options are: <p/> *  * <pre> -i &lt;the input file&gt; * The input file</pre> *  * <pre> -o &lt;the output file&gt; * The output file</pre> *  <!-- options-end --> * * @author Stefan Mutter (mutter@cs.waikato.ac.nz) * @version $Revision: 1.6 $ * @see Saver */public class SerializedInstancesSaver   extends AbstractFileSaver   implements BatchConverter {  /** for serialization */  static final long serialVersionUID = -7717010648500658872L;    /** Constructor */    public SerializedInstancesSaver(){      resetOptions();  }      /**   * Returns a string describing this Saver   *    * @return a description of the Saver suitable for   * displaying in the explorer/experimenter gui   */  public String globalInfo() {    return "Serializes the instances to a file with extension bsi.";  }   /**   * Returns a description of the file type.   *   * @return a short file description   */  public String getFileDescription() {    return "Binary serialized instances";  }  /**   * Resets the Saver    */  public void resetOptions() {    super.resetOptions();    setFileExtension(".bsi");  }  /**    * Returns the Capabilities of this saver.   *   * @return            the capabilities of this object   * @see               Capabilities   */  public Capabilities getCapabilities() {    Capabilities result = super.getCapabilities();        // attributes    result.enableAllAttributes();    result.enable(Capability.MISSING_VALUES);        // class    result.enableAllClasses();    result.enable(Capability.MISSING_CLASS_VALUES);    result.enable(Capability.NO_CLASS);        return result;  }    /**    * Writes a Batch of instances   *    * @throws IOException throws IOException if saving in batch mode is not possible   */  public void writeBatch() throws IOException {            resetWriter();            if(getRetrieval() == INCREMENTAL)          throw new IOException("Batch and incremental saving cannot be mixed.");      if(getInstances() == null)          throw new IOException("No instances to save");      setRetrieval(BATCH);      if(retrieveFile() == null){        throw new IOException("No output to standard out for serialization.");      }      setWriteMode(WRITE);      ObjectOutputStream outW = 		  new ObjectOutputStream(		  new BufferedOutputStream(		  new FileOutputStream(retrieveFile())));      outW.writeObject(getInstances());      outW.flush();      outW.close();      setWriteMode(WAIT);      outW = null;      resetWriter();      setWriteMode(CANCEL);  }  /**   * Main method.   *   * @param args should contain the options of a Saver.   */  public static void main(String[] args) {    runFileSaver(new SerializedInstancesSaver(), args);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -