当前位置: 首页>>代码示例>>Java>>正文


Java FSTObjectOutput.close方法代码示例

本文整理汇总了Java中org.nustaq.serialization.FSTObjectOutput.close方法的典型用法代码示例。如果您正苦于以下问题:Java FSTObjectOutput.close方法的具体用法?Java FSTObjectOutput.close怎么用?Java FSTObjectOutput.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.nustaq.serialization.FSTObjectOutput的用法示例。


在下文中一共展示了FSTObjectOutput.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: FSWrite

import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
private boolean FSWrite(String filepath, String tag) {
    try {
        if (!tag.equals("")) {
            tag = "_" + tag;
        }
        Logger.getRootLogger().info("Writing ID results to file:" + FilenameUtils.getFullPath(filepath) + FilenameUtils.getBaseName(filepath) + tag + "_LCMSID.serFS...");
        FileOutputStream fout = new FileOutputStream(FilenameUtils.getFullPath(filepath) + FilenameUtils.getBaseName(filepath) + tag + "_LCMSID.serFS", false);
        FSTObjectOutput out = new FSTObjectOutput(fout);
        ReduceMemoryUsage();
        out.writeObject(this, LCMSID.class);
        out.close();
        fout.close();
    } catch (Exception ex) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
        return false;
    }
    return true;
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:19,代码来源:LCMSID.java

示例2: main

import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();

    SomeMediumClass mediumClass = new SomeMediumClass();
    byte barray[] = conf.asByteArray(mediumClass);
    System.out.println(barray.length);
    SomeMediumClass object = (SomeMediumClass)conf.asObject(barray);
    System.out.println(object);


    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    FSTObjectOutput output = new FSTObjectOutput(outputStream);
    output.writeObject(mediumClass);
    output.close();

    FSTObjectInput input = new FSTObjectInput(new ByteArrayInputStream(outputStream.toByteArray()));
    object = (SomeMediumClass)input.readObject(SomeMediumClass.class);
    System.out.println(object);
}
 
开发者ID:chuidiang,项目名称:chuidiang-ejemplos,代码行数:20,代码来源:FstExample.java

示例3: testWriteReplaceInList

import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
@Test
public void testWriteReplaceInList() throws IOException, ClassNotFoundException {
	Container c = new Container();

	BaseClass b1 = new BaseClass();
	b1.value = "morphMe";
	c.list.add(b1);
	BaseClass b2 = new BaseClass();
	b2.value = "morphMe";
	c.list.add(b2);

	ByteArrayOutputStream buf = new ByteArrayOutputStream();
	FSTObjectOutput out = new FSTObjectOutput(buf, getTestConfiguration());
	out.writeObject(c);
	out.close();

	ObjectInput in = getTestConfiguration().getObjectInput(new ByteArrayInputStream(buf.toByteArray()));
	Container res = (Container) in.readObject();
	assertEquals("you have morphed", ((Morpher) res.list.get(0)).value);
	assertEquals("you have morphed", ((Morpher) res.list.get(1)).value);
}
 
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:22,代码来源:TestWriteReplaceInList.java

示例4: testWithStreams

import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
@Test
public void testWithStreams() throws IOException, ClassNotFoundException {
    HashMap hm = createHM();
    HashMap hm1 = createHM1(hm);

    FSTObjectOutput out = new FSTObjectOutput(new FileOutputStream("../epsis.oos"));
    out.writeObject(hm);
    out.writeObject(hm1);
    out.close();

    FSTObjectInput in = new FSTObjectInput(new FileInputStream("../epsis.oos"));
    HashMap o1 = (HashMap) in.readObject();
    HashMap o2 = (HashMap) in.readObject();
    in.close();
    Assert.assertTrue(DeepEquals.deepEquals(o1, hm));
    Assert.assertTrue(DeepEquals.deepEquals(o2, hm1));
}
 
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:18,代码来源:BigObjTest.java

示例5: LibraryMatchWrite

import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
public boolean LibraryMatchWrite() throws FileNotFoundException {
    try {
        Logger.getRootLogger().info("Writing Target match results to file:" + FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + LibID + "_LibMatch.serFS...");
        FileOutputStream fout = new FileOutputStream(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + LibID + "_LibMatch.serFS", false);
        FSTObjectOutput out = new FSTObjectOutput(fout);
        out.writeObject(this);
        out.close();
        fout.close();
    } catch (Exception ex) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
        return false;
    }
    return true;
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:15,代码来源:TargetMatchScoring.java

示例6: FasterSerialzationWrite

import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
public boolean FasterSerialzationWrite(String Filename) throws FileNotFoundException {
    try {
        org.apache.log4j.Logger.getRootLogger().info("Writing fasta serialization to file:" + FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + ".FastaSer...");
        FileOutputStream fout = new FileOutputStream(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + ".FastaSer", false);
        FSTObjectOutput out = new FSTObjectOutput(fout);
        out.writeObject(this);
        out.close();
        fout.close();
    } catch (Exception ex) {
        org.apache.log4j.Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
        return false;
    }
    return true;
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:15,代码来源:FastaParser.java

示例7: FSFragmentLibWrite

import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
private void FSFragmentLibWrite(String path, String LibID1) {
    try {
        Logger.getRootLogger().info("Writing FragmentLib to file:" + path + LibID1 + ".serFS...");
        FileOutputStream fout = new FileOutputStream(path + LibID1 + ".serFS", false);
        FSTObjectOutput oos = new FSTObjectOutput(fout);
        oos.writeObject(this);
        oos.close();
        fout.close();
    } catch (Exception ex) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
    }
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:13,代码来源:FragmentLibManager.java

示例8: FS_PeakClusterWrite

import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
private void FS_PeakClusterWrite() {
    try {
        Logger.getRootLogger().info("Writing PeakCluster serialization to file:" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.serFS...");
        FileOutputStream fout = new FileOutputStream(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.serFS", false);
        FSTObjectOutput out = new FSTObjectOutput(fout);
        out.writeObject(PeakClusters);
        out.close();
        fout.close();
    } catch (Exception ex) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
        JavaSerializationPeakClusterWrite();
    }
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:14,代码来源:LCMSPeakBase.java

示例9: FSCluster2CurveWrite

import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
private void FSCluster2CurveWrite() {
    try {
        Logger.getRootLogger().debug("Writing PrecursorFragmentCorr serialization to file:" + FilenameUtils.getBaseName(ScanCollectionName) + "_Clus2Cur.serFS...");
        FileOutputStream fout = new FileOutputStream(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_Clus2Cur.serFS", false);
        FSTObjectOutput oos = new FSTObjectOutput(fout);
        oos.writeObject(FragmentsClu2Cur);
        oos.close();
        fout.close();
    } catch (Exception ex) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
    }
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:13,代码来源:LCMSPeakDIAMS2.java

示例10: FSCluster2CurveUnfragWrite

import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
private void FSCluster2CurveUnfragWrite() {
    try {
        Logger.getRootLogger().debug("Writing UnfragPrecursorFragCorr serialization to file:" + FilenameUtils.getBaseName(ScanCollectionName) + "_UnfClus2Cur.serFS...");
        FileOutputStream fout = new FileOutputStream(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_UnfClus2Cur.serFS", false);
        FSTObjectOutput oos = new FSTObjectOutput(fout);
        oos.writeObject(UnFragIonClu2Cur);
        oos.close();
        fout.close();
    } catch (Exception ex) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
    }
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:13,代码来源:LCMSPeakDIAMS2.java

示例11: FSScanPosWrite

import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
private void FSScanPosWrite() {
    try {
        Logger.getRootLogger().debug("Writing ScanPos to file:" + FilenameUtils.removeExtension(filename) + ".ScanPosFS..");
        FileOutputStream fout = new FileOutputStream(FilenameUtils.removeExtension(filename) + ".ScanPosFS", false);
        FSTObjectOutput oos = new FSTObjectOutput(fout);
        oos.writeObject(ScanIndex);
        oos.close();
        fout.close();
    } catch (Exception ex) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
    }
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:13,代码来源:mzXMLParser.java

示例12: writeToFileFSTObject

import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
/**
 * Writes a cache block to disk using FST object output streams
 * 
 * @param fileNumber The file number to write to
 * @param cacheSpot The block to write to disk
 * @param arrayList The BigArrayList
 * @throws IOException For I/O errors
 */
protected void writeToFileFSTObject(int fileNumber, int cacheSpot, BigArrayList<E> arrayList) throws IOException
{
	String filePath = memoryPath + File.separator + memoryInstance + "_memory_" + fileNumber + memoryExtension;

	File tempFile = new File(filePath);
	
	if(!arrayList.getList(cacheSpot).isEmpty())
	{
		tempFile.deleteOnExit();
	
		FileOutputStream fileOutputStream = new FileOutputStream(filePath);
		FSTObjectOutput fstObjectOutputStream = new FSTObjectOutput(fileOutputStream);

		try
		{
			byte byteArray[] = fstConfiguration.asByteArray(arrayList.getList(cacheSpot));
			fstObjectOutputStream.write(byteArray);
			fstObjectOutputStream.flush();
		}
		catch(IOException ioe)
		{
			throw ioe;
		}
		finally
		{
			fileOutputStream.close();
			fstObjectOutputStream.close();
		}
	}
	else
	{
		tempFile.delete();
	}
}
 
开发者ID:dselent,项目名称:BigArrayList,代码行数:43,代码来源:FileAccessor.java

示例13: testMapWriteReplace

import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
@Test
public void testMapWriteReplace() throws Exception {
    Map<String, Object> map = new MyMap<>();
    map.put("value", 1234.5);

    Map<String, Object> map1 = new MyMap<>();
    map1.put("othervalue", 5678.9);

    ByteArrayOutputStream buf = new ByteArrayOutputStream();
    FSTObjectOutput out = new FSTObjectOutput(buf, getTestConfiguration());
    out.writeObject(map);
    out.writeObject(map1);
    out.writeObject("Ensure Stream is not corrupted");
    out.close();

    FSTObjectInput in = getTestConfiguration().getObjectInput(new ByteArrayInputStream(buf.toByteArray()));
    Map<?, ?> res = (Map<?, ?>) in.readObject();
    Map<?, ?> res1 = (Map<?, ?>) in.readObject();
    in.close();

    assertEquals(LinkedHashMap.class, res.getClass());
    assertEquals(1, res.size());
    assertEquals(1234.5, res.get("value"));
    assertEquals(LinkedHashMap.class, res1.getClass());
    assertEquals(1, res1.size());
    assertEquals(5678.9, res1.get("othervalue"));
}
 
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:28,代码来源:Github204.java

示例14: writeForNetwork

import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
public void writeForNetwork(FSTObjectOutput out) throws IOException {
    out.writeObject(this, Parameters.class);
    out.close();
}
 
开发者ID:numenta,项目名称:htm.java,代码行数:5,代码来源:Parameters.java

示例15: serializationTest

import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
@Test
public void serializationTest() throws IOException, ClassNotFoundException {
	// Instantiation of the ExternalizableTestClass object
	int integer = 10;
	String path = "path";
	ExternalizableTestClass object = new ExternalizableTestClass(integer, path);
	Set<ExternalizableTestClass> set = new HashSet<ExternalizableTestClass>();
	set.add(object);
	BeanTestClass2 bean = new BeanTestClass2(object, set);

	// when serialized and deserialized, the integer value of all ExternalizableTestClass objects should be
	// overwritten by readResolve and set to 1.

	// Java
	// 1. serialize
	byte[] data1;
	try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(bos)) {
		out.writeObject(bean);
		data1 = bos.toByteArray();
	}

	// 2. deserialize
	BeanTestClass2 bean1;
	try (ByteArrayInputStream bis = new ByteArrayInputStream(data1); ObjectInput in = new ObjectInputStream(bis)) {
		bean1 = (BeanTestClass2) in.readObject();
	}

	Assert.assertEquals(1, bean1.getObject().getInteger());
	Assert.assertEquals(1, ((ExternalizableTestClass) bean1.getSet().toArray()[0]).getInteger());

	// FST
	// 1. serialize
	FSTConfiguration config = FSTConfiguration.createDefaultConfiguration();
	FSTObjectOutput out2 = config.getObjectOutput();
	out2.writeObject(bean);
	byte[] data2 = out2.getCopyOfWrittenBuffer();
	out2.close();

	// 2. deserialize
	BeanTestClass2 bean2 = (BeanTestClass2) config.getObjectInput(data2).readObject();
	
	Assert.assertEquals(1, bean2.getObject().getInteger());
	Assert.assertEquals(1, ((ExternalizableTestClass) bean2.getSet().toArray()[0]).getInteger());
}
 
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:45,代码来源:TestFastSerializationBean2.java


注:本文中的org.nustaq.serialization.FSTObjectOutput.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。