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


Java ObjectInputStream.close方法代码示例

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


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

示例1: getObjectFromBlob

import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
 * <p>
 * This method should be overridden by any delegate subclasses that need
 * special handling for BLOBs. The default implementation uses standard
 * JDBC <code>java.sql.Blob</code> operations.
 * </p>
 * 
 * @param rs
 *          the result set, already queued to the correct row
 * @param colName
 *          the column name for the BLOB
 * @return the deserialized Object from the ResultSet BLOB
 * @throws ClassNotFoundException
 *           if a class found during deserialization cannot be found
 * @throws IOException
 *           if deserialization causes an error
 */
protected Object getObjectFromBlob(ResultSet rs, String colName)
    throws ClassNotFoundException, IOException, SQLException {
    Object obj = null;

    Blob blobLocator = rs.getBlob(colName);
    if (blobLocator != null && blobLocator.length() != 0) {
        InputStream binaryInput = blobLocator.getBinaryStream();

        if (null != binaryInput) {
            if (binaryInput instanceof ByteArrayInputStream
                && ((ByteArrayInputStream) binaryInput).available() == 0 ) {
                //do nothing
            } else {
                ObjectInputStream in = new ObjectInputStream(binaryInput);
                try {
                    obj = in.readObject();
                } finally {
                    in.close();
                }
            }
        }

    }
    return obj;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:43,代码来源:StdJDBCDelegate.java

示例2: getInstance

import java.io.ObjectInputStream; //导入方法依赖的package包/类
public static Inbox getInstance()
{
	if(instance != null) return instance;
	File file = new File(InboxVariables.inboxFile);
	if(file.exists())
	{
		try
		{
			FileInputStream fin = new FileInputStream(file);
			ObjectInputStream oin = new ObjectInputStream(fin);
			instance = (Inbox)oin.readObject();
			oin.close();
			fin.close();
		}
		catch(Exception ex)
		{
			ex.printStackTrace(System.err);
		}
	}
	// if not just create a new instance
	else
	{
		instance = new Inbox();
	}
	return instance;
}
 
开发者ID:travispessetto,项目名称:OrigamiSMTP,代码行数:27,代码来源:Inbox.java

示例3: loadUidList

import java.io.ObjectInputStream; //导入方法依赖的package包/类
private boolean loadUidList(File uidFile) {
    if (!uidFile.exists()) {
        return false;
    }
    try {
        ObjectInputStream is = new ObjectInputStream(new FileInputStream(uidFile));
        mFreeUid = is.readInt();
        //noinspection unchecked
        Map<String, Integer> map = (HashMap<String, Integer>) is.readObject();
        mSharedUserIdMap.putAll(map);
        is.close();
    } catch (Throwable e) {
        return false;
    }
    return true;
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:17,代码来源:UidSystem.java

示例4: JavaSerializationPeakClusterRead

import java.io.ObjectInputStream; //导入方法依赖的package包/类
private boolean JavaSerializationPeakClusterRead() {
    if (!new File(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.ser").exists()) {
        return false;
    }
    try {
        Logger.getRootLogger().info("Reading PeakCluster serialization from file:" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.ser...");

        FileInputStream fileIn = new FileInputStream(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.ser");
        ObjectInputStream in = new ObjectInputStream(fileIn);
        PeakClusters = (ArrayList<PeakCluster>) in.readObject();
        in.close();
        fileIn.close();
    } catch (Exception ex) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
        return false;
    }
    return true;
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:19,代码来源:LCMSPeakBase.java

示例5: getObjectFromBlob

import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 * <p>
 * Caché requires {@code java.sql.Blob} instances to be explicitly freed.
 */
@Override
protected Object getObjectFromBlob(ResultSet rs, String colName) throws ClassNotFoundException, IOException, SQLException {
    Blob blob = rs.getBlob(colName);
    if (blob == null) {
        return null;
    } else {
        try {
            if (blob.length() == 0) {
                return null;
            } else {
                InputStream binaryInput = blob.getBinaryStream();
                if (binaryInput == null) {
                    return null;
                } else if (binaryInput instanceof ByteArrayInputStream && ((ByteArrayInputStream) binaryInput).available() == 0 ) {
                    return null;
                } else {
                    ObjectInputStream in = new ObjectInputStream(binaryInput);
                    try {
                        return in.readObject();
                    } finally {
                        in.close();
                    }
                }
            }
        } finally {
            blob.free();
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:CacheDelegate.java

示例6: deserializeBlock

import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
 * Thread method that deserializes the given range of array indices.
 *
 * @param blockId The id of the array block being deserialized.
 */
private void deserializeBlock(int blockId) {
    logger.info(String.format("Deserializing block %s of %s", blockId, getArrayName()));
    long blockBeginTimeInNano = System.nanoTime();
    try {
        ObjectInputStream objectInputStream = IO.constructObjectInputStream(
            SerDeUtils.getArrayBlockFilePath(directoryPath, getClassName(), getArrayName(),
                blockId));
        int startIndexOfBlock = objectInputStream.readInt();
        int endIndexOfBlock = objectInputStream.readInt();
        for (int i = startIndexOfBlock; i <= endIndexOfBlock; i++) {
            deserializeArrayCell(objectInputStream, i);
        }
        objectInputStream.close();
        logger.info(String.format("%s block %s (from %s to %s) of %s deserialized in %.3f ms.",
            getArrayName(), blockId, startIndexOfBlock, endIndexOfBlock, getClassName(),
            IO.getElapsedTimeInMillis(blockBeginTimeInNano)));
    } catch (IOException | ClassNotFoundException e) {
        logger.error(String.format("Error deserializing block %s of %s", blockId,
            getArrayName()), e);
        throw new SerializationDeserializationException("Error in deserialization");
    }
}
 
开发者ID:graphflow,项目名称:graphflow,代码行数:28,代码来源:ParallelArraySerDeUtils.java

示例7: nullSafeGetInternal

import java.io.ObjectInputStream; //导入方法依赖的package包/类
@Override
protected Object nullSafeGetInternal(
		ResultSet rs, String[] names, Object owner, LobHandler lobHandler)
		throws SQLException, IOException, HibernateException {

	InputStream is = lobHandler.getBlobAsBinaryStream(rs, names[0]);
	if (is != null) {
		ObjectInputStream ois = new ObjectInputStream(is);
		try {
			return ois.readObject();
		}
		catch (ClassNotFoundException ex) {
			throw new HibernateException("Could not deserialize BLOB contents", ex);
		}
		finally {
			ois.close();
		}
	}
	else {
		return null;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:BlobSerializableType.java

示例8: load

import java.io.ObjectInputStream; //导入方法依赖的package包/类
public static StatisticalSummary load(String path) {
	try {
		ObjectInputStream ois = new ObjectInputStream(new FileInputStream(path));
		StatisticalSummary ss = (StatisticalSummary) ois.readObject();
		ois.close();
		return ss;
	} catch (Exception e) {
		System.out.println(e);
		return null;
	}
}
 
开发者ID:CognitiveModeling,项目名称:BrainControl,代码行数:12,代码来源:StatisticalSummary.java

示例9: readFromFile

import java.io.ObjectInputStream; //导入方法依赖的package包/类
private void readFromFile(String fn) throws IOException, ClassNotFoundException {
    File file = new File(fn);
    FileInputStream f = new FileInputStream(file);
    ObjectInputStream s = new ObjectInputStream(f);
    MinterestMap = (HashMap<String, String>) s.readObject();
    MinterestResultMap = (HashMap<String, Set<String>>) s.readObject();
    rMinterestMap = (HashMap<String, String>) s.readObject();
    rMinterestResultMap = (HashMap<String, Set<String>>) s.readObject();
    FinterestMap = (HashMap<String, String>) s.readObject();
    FinterestResultMap = (HashMap<String, Set<String>>) s.readObject();
    s.close();
}
 
开发者ID:Alexandre-Bartel,项目名称:permission-map,代码行数:13,代码来源:FindTargetMethod.java

示例10: hent

import java.io.ObjectInputStream; //导入方法依赖的package包/类
public static Object hent(String filnavn) throws Exception {
  FileInputStream datastrøm = new FileInputStream(filnavn);
  ObjectInputStream objektstrøm = new ObjectInputStream(datastrøm);
  Object obj = objektstrøm.readObject();
  objektstrøm.close();
  return obj;
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:8,代码来源:Serialisering.java

示例11: serDeser

import java.io.ObjectInputStream; //导入方法依赖的package包/类
private static HashSet<Integer> serDeser(HashSet<Integer> hashSet) throws IOException, ClassNotFoundException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(hashSet);
    oos.flush();

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(bais);
    HashSet<Integer> result = (HashSet<Integer>)ois.readObject();

    oos.close();
    ois.close();

    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:Serialization.java

示例12: getObjectDeserializingIfNeeded

import java.io.ObjectInputStream; //导入方法依赖的package包/类
private Object getObjectDeserializingIfNeeded(int columnIndex) throws SQLException {
    final Field field = this.fields[columnIndex - 1];

    if (field.isBinary() || field.isBlob()) {
        byte[] data = getBytes(columnIndex);

        if (this.connection.getAutoDeserialize()) {
            Object obj = data;

            if ((data != null) && (data.length >= 2)) {
                if ((data[0] == -84) && (data[1] == -19)) {
                    // Serialized object?
                    try {
                        ByteArrayInputStream bytesIn = new ByteArrayInputStream(data);
                        ObjectInputStream objIn = new ObjectInputStream(bytesIn);
                        obj = objIn.readObject();
                        objIn.close();
                        bytesIn.close();
                    } catch (ClassNotFoundException cnfe) {
                        throw SQLError.createSQLException(Messages.getString("ResultSet.Class_not_found___91") + cnfe.toString()
                                + Messages.getString("ResultSet._while_reading_serialized_object_92"), getExceptionInterceptor());
                    } catch (IOException ex) {
                        obj = data; // not serialized?
                    }
                } else {
                    return getString(columnIndex);
                }
            }

            return obj;
        }

        return data;
    }

    return getBytes(columnIndex);
}
 
开发者ID:Jugendhackt,项目名称:OpenVertretung,代码行数:38,代码来源:ResultSetImpl.java

示例13: loadHistogramFromFile

import java.io.ObjectInputStream; //导入方法依赖的package包/类
public void loadHistogramFromFile(File file) {
    try {
        FileInputStream fis = new FileInputStream(file);
        ObjectInputStream ois = new ObjectInputStream(fis);
        setHistmax((Integer) ois.readObject());
        histogram = (int[][]) ois.readObject();
        bitmap=(boolean[][]) ois.readObject();
        setThreshold(ois.readFloat());
        numX=0; numY=0;
        if(histogram!=null){
            numX=histogram.length;
            if(histogram[0]!=null){
                numY=histogram[0].length;
            }
        }
        numPix = numX * numY;
        computeTotalSum(); // in case loaded from file
        computeErodedBitmap(); // in case not stored
        ois.close();
        fis.close();
        log.info("histogram loaded from (usually host/java) file " + file.getPath() + "; histmax=" + histmax);
        setFilePath(file.getPath());

    } catch (Exception e) {
        log.info("couldn't load histogram from file " + file + ": " + e.toString());
    }
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:28,代码来源:Histogram2DFilter.java

示例14: testLargeString

import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
 * 
 * Test write/read of a large string (> 64Kb)
 *
 * @throws Exception
 */
@Test
public void testLargeString() throws Exception
{
    ObjectOutputStream dos = new ObjectOutputStream( fos );
    ObjectInputStream dis = new ObjectInputStream( fis );
    char[] fill = new char[196622]; // 65535 * 3 + 17
    Arrays.fill( fill, '\u00fc' ); // German &&uuml
    String testString = new String( fill );
    Unicode.writeUTF( dos, testString );
    dos.flush();
    dos.close();
    assertEquals( testString, Unicode.readUTF( dis ) );
    dis.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:UnicodeTest.java

示例15: readInContext

import java.io.ObjectInputStream; //导入方法依赖的package包/类
public NamingContextImpl readInContext(String objKey)
{
    NamingContextImpl context = (NamingContextImpl) contexts.get(objKey);
    if( context != null )
    {
            // Returning Context from Cache
            return context;
    }

    File contextFile = new File(logDir, objKey);
    if (contextFile.exists()) {
        try {
            FileInputStream fis = new FileInputStream(contextFile);
            ObjectInputStream ois = new ObjectInputStream(fis);
            context = (NamingContextImpl) ois.readObject();
            context.setORB( orb );
            context.setServantManagerImpl( this );
            context.setRootNameService( theNameService );
            ois.close();
        } catch (Exception ex) {
        }
    }

    if (context != null)
    {
            contexts.put(objKey, context);
    }
    return context;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:ServantManagerImpl.java


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