保存到路径

@param modelFile
@throws IOException
3647
public void save(String modelFile) throws IOException
    {
        DataOutputStream out = new DataOutputStream(new BufferedOutputStream(IOUtil.newOutputStream(modelFile)));
        save(out);
        out.close();
    }
311399
def save(self, source: IO):
        
        write = source.write

        write(pack(
            '>IHH',
            ClassFile.MAGIC,
            self.version.minor,
            self.version.major
        ))

        self._constants.pack(source)

        write(self.access_flags.pack())
        write(pack(
            f'>HHH{len(self._interfaces)}H',
            self._this,
            self._super,
            len(self._interfaces),
            *self._interfaces
        ))

        self.fields.pack(source)
        self.methods.pack(source)
        self.attributes.pack(source)
407186
public void load(String modelFile) throws IOException
    {
        if (HanLP.Config.DEBUG)
            logger.start("加载 %s ... ", modelFile);
        ByteArrayStream byteArray = ByteArrayStream.createByteArrayStream(modelFile);
        if (!load(byteArray))
        {
            throw new IOException(String.format("%s 加载失败", modelFile));
        }
        if (HanLP.Config.DEBUG)
            logger.finish(" 加载完毕\n");
    }
796793
@Override
    public void savePolicy(Model model) {
        if (filePath.equals("")) {
            throw new Error("invalid file path, file path cannot be empty");
        }

        StringBuilder tmp = new StringBuilder();

        for (Map.Entry<String, Assertion> entry : model.model.get("p").entrySet()) {
            String ptype = entry.getKey();
            Assertion ast = entry.getValue();

            for (List<String> rule : ast.policy) {
                tmp.append(ptype + ", ");
                tmp.append(Util.arrayToString(rule));
                tmp.append("\n");
            }
        }

        for (Map.Entry<String, Assertion> entry : model.model.get("g").entrySet()) {
            String ptype = entry.getKey();
            Assertion ast = entry.getValue();

            for (List<String> rule : ast.policy) {
                tmp.append(ptype + ", ");
                tmp.append(Util.arrayToString(rule));
                tmp.append("\n");
            }
        }

        savePolicyFile(tmp.toString().trim());
    }
978700
public synchronized void save() throws IOException {
        if(BulkChange.contains(this))   return;

        long start=0;
        if(logger.isLoggable(Level.FINE))
            start = System.currentTimeMillis();

        File file = getFingerprintFile(md5sum);
        save(file);
        SaveableListener.fireOnChange(this, getConfigFile(file));

        if(logger.isLoggable(Level.FINE))
            logger.fine("Saving fingerprint "+file+" took "+(System.currentTimeMillis()-start)+"ms");
    }
54320
def save(self, model_file, save_dir, verbose=True):
        

        # Check existence of model saving directory and create if does not exist.
        if not os.path.exists(save_dir):
            os.makedirs(save_dir)

        params = {
            "model": self.state_dict(),
            "cardinality": self.cardinality,
            "name": self.name,
            "config": self.settings,
        }

        try:
            torch.save(params, f"{save_dir}/{model_file}")
        except BaseException:
            self.logger.warning("Saving failed... continuing anyway.")

        if verbose:
            self.logger.info(f"[{self.name}] Model saved as {model_file} in {save_dir}")
695996
public void save(@NonNull File meanFile, @NonNull File stdFile) throws IOException {
        Nd4j.saveBinary(getMean(), meanFile);
        Nd4j.saveBinary(getStd(), stdFile);
    }
1009112
private void saveFeatureIndexes(FeatureIndex[] index, ZipModel model) throws IOException
	{
		logger.info(" (" + index.length + ")");

		// save the indexes
		for (int i=0;i<index.length;i++)
		{
			logger.debug("dic" + i + " size " + index[i].size());

			File tmp = File.createTempFile("dic" + i, null);
			tmp.deleteOnExit();

			BufferedWriter bwd = new BufferedWriter(new FileWriter(tmp));
			index[i].write(bwd);
			bwd.close();

			// add the dictionary to the model
			model.add(tmp, "dic" + i);
		} // end for
	}
737964
public void storeSettingsToFile(File file) throws IOException {
    FileOutputStream fos = new FileOutputStream(file);
    this.conf.writeXml(fos);
    fos.close();
  }
1158146
public void save(String file) throws IOException,FileNotFoundException
	{
		ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file));
		oos.writeObject(blockerNames);
		oos.writeObject(datasetNames);
		oos.writeObject(learnerNames);
		oos.writeObject(expt);
		oos.close();
	}
328311
public void save() throws IOException
    {
        try
        {
            Future<Void> task = saveNB();
            task.get();
        }
        catch (ExecutionException e)
        {
            Throwable t = e.getCause();

            if (t instanceof IOException)
            {
                throw (IOException)t;
            }

            throw new IOException(t);
        }
        catch (InterruptedException e)
        {
            throw new IOException("Saving of the properties file \"" + getFile().getAbsolutePath()
                                  + "\" was interrupted.");
        }
    }
1289225
public static void writeModel(@NonNull Model model, @NonNull OutputStream stream, boolean saveUpdater)
            throws IOException {
        writeModel(model,stream,saveUpdater,null);
    }
1130149
public void saveToFile(String outputFile) throws FileNotFoundException, IOException {
    Streams.copy(getInputStream(), new BufferedOutputStream(new FileOutputStream(outputFile)));
  }
1337848
@Override
	public void saveDocument(IProject project, File projectRoot, String name, boolean modelOnly)
			throws IOException
	{
		String document = readFile("latex/document.tex");
		String documentFileName = name;// + ".tex";
		File latexRoot = makeOutputFolder(project);
		StringBuilder sb = new StringBuilder();
		String title = // "Coverage Report: " +
		projectRoot.getName().replace('\\', '/').substring(0, projectRoot.getName().length());

		for (String path : includes)
		{

			String includeName = path;
			includeName = includeName.substring(0, includeName.lastIndexOf('.'));
			includeName = includeName.substring(0, includeName.lastIndexOf('.'));
			String tmp = includeName.replace('\\', '/');
			includeName = tmp.substring(tmp.lastIndexOf('/') + 1);

			if(modelOnly){
			sb.append("\n" + "\\section{" + latexQuote(includeName) + "}");
			}

			if (path.contains(latexRoot.getAbsolutePath()))
			{
				path = path.substring(latexRoot.getAbsolutePath().length());
				// sb.append("\n" + "\\input{" + (".." + path).replace('\\',
				// '/')
				// + "}");
				sb.append("\n" + "\\input{"
						+ path.replace('\\', '/').substring(1, path.length())
						+ "}");
			} else
			{
				sb.append("\n" + "\\input{" + path.replace('\\', '/') + "}");
			}

		}
		document = document.replace(TITLE, latexQuote(title)).replace(PROJECT_INCLUDE_MODEL_FILES, sb.toString());

		writeFile(outputFolder, documentFileName, document);
	}
249668
public void save(File file) throws IOException {
        BufferedImage bi = new BufferedImage(canvas.getWidth(), canvas.getHeight(), BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2d = bi.createGraphics();
        canvas.print(g2d);

        ImageIO.write(bi, FileChooser.getExtension(file), file);
    }
842143
def save_model(model, filename):
    
    with open(filename, 'w') as f:
        f.write(serialize_model(model))
611274
public void saveTo(File file) throws IOException {
		FileWriter writer = new FileWriter(file);
		try {
			writer.write(getAbcString());
		} finally {
			writer.close();
		}
	}