本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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));
}
示例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;
}
示例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;
}
示例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));
}
}
示例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();
}
}
示例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));
}
}
示例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));
}
}
示例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));
}
}
示例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();
}
}
示例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"));
}
示例14: writeForNetwork
import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
public void writeForNetwork(FSTObjectOutput out) throws IOException {
out.writeObject(this, Parameters.class);
out.close();
}
示例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());
}