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


Java ObjectInput类代码示例

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


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

示例1: readExternal

import java.io.ObjectInput; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void readExternal(ObjectInput in)
  throws IOException, ClassNotFoundException
{
  int size = in.readInt();

  if (size > 0)
  _rows = (Map<DualKey, Object>) in.readObject();

  if (_LOG.isFinest())
  {
    for(Map.Entry<DualKey, Object> entry : _rows.entrySet())
    {
      _LOG.finest("Restoring " + entry.getKey() + ", " + entry.getValue());
    }
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:18,代码来源:StampState.java

示例2: testSerialization

import java.io.ObjectInput; //导入依赖的package包/类
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    // test a default instance
    DialValueIndicator i1 = new DialValueIndicator(0, "Label");
    DialValueIndicator i2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(i1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        i2 = (DialValueIndicator) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(i1, i2);
    
    // test a custom instance
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:DialValueIndicatorTests.java

示例3: testSerialization

import java.io.ObjectInput; //导入依赖的package包/类
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    VectorRenderer r1 = new VectorRenderer();
    VectorRenderer r2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(r1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        r2 = (VectorRenderer) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(r1, r2);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:23,代码来源:VectorRendererTests.java

示例4: testSerialization

import java.io.ObjectInput; //导入依赖的package包/类
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    StandardXYLabelGenerator g1 = new StandardXYLabelGenerator();
    StandardXYLabelGenerator g2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(g1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        g2 = (StandardXYLabelGenerator) in.readObject();
        in.close();
    }
    catch (Exception e) {
        System.out.println(e.toString());
    }
    assertEquals(g1, g2);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:StandardXYLabelGeneratorTests.java

示例5: readExternal

import java.io.ObjectInput; //导入依赖的package包/类
/** {@inheritDoc} */
public void readExternal(ObjectInput in)
        throws IOException, ClassNotFoundException {

    // VERSION
    in.readByte();

    // NO_ENTRY_VALUE
    no_entry_value = in.readChar();

    // ENTRIES
    int len = in.readInt();
    for (int i = 0; i < len; i++) {
        add(in.readChar());
    }
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:17,代码来源:TCharLinkedList.java

示例6: readSafely

import java.io.ObjectInput; //导入依赖的package包/类
/** Reads an object from the given object input.
* The object had to be saved by the {@link NbObjectOutputStream#writeSafely} method.
*
* @param oi object input
* @return the read object
* @exception IOException if IO error occured
* @exception SafeException if the operation failed but the stream is ok
*    for further reading
*/
public static Object readSafely(ObjectInput oi) throws IOException {
    int size = oi.readInt();
    byte[] byteArray = new byte[size];
    oi.readFully(byteArray, 0, size);

    try {
        ByteArrayInputStream bis = new ByteArrayInputStream(byteArray);
        NbObjectInputStream ois = new NbObjectInputStream(bis);
        Object obj = ois.readObject();
        bis.close();

        return obj;
    } catch (Exception exc) {
        // encapsulate all exceptions into safe exception
        throw new SafeException(exc);
    } catch (LinkageError le) {
        throw new SafeException(new InvocationTargetException(le));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:NbObjectInputStream.java

示例7: readExternal

import java.io.ObjectInput; //导入依赖的package包/类
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   	super.readExternal(in);
   	iExpirationDate = (in.readBoolean() ? new Date(in.readLong()) : null);
   	
   	int nrConfigs = in.readInt();
   	iConfigs.clear();
   	for (int i = 0; i < nrConfigs; i++)
   		iConfigs.add(in.readLong());
   	
   	int nrSubparts = in.readInt();
   	iSections.clear(); 
   	for (int i = 0; i < nrSubparts; i++) {
   		Set<Long> sections = new HashSet<Long>();
   		iSections.put(in.readLong(), sections);
   		int nrSection = in.readInt();
   		for (int j = 0; j < nrSection; j++) {
   			sections.add(in.readLong());
   		}
   	}
   	iLimitCap = in.readInt();
   	iRestrictivity = in.readDouble();
   	iPriority = in.readInt();
   	iFlags = in.readInt();
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:26,代码来源:XReservation.java

示例8: testSerialization

import java.io.ObjectInput; //导入依赖的package包/类
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    IntervalCategoryLabelGenerator g1
        = new IntervalCategoryLabelGenerator("{3} - {4}", DateFormat.getInstance());
    IntervalCategoryLabelGenerator g2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(g1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        g2 = (IntervalCategoryLabelGenerator) in.readObject();
        in.close();
    }
    catch (Exception e) {
        System.out.println(e.toString());
    }
    assertEquals(g1, g2);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:IntervalCategoryLabelGeneratorTests.java

示例9: readExternal

import java.io.ObjectInput; //导入依赖的package包/类
public void readExternal( ObjectInput in )
	throws IOException, ClassNotFoundException {

	// VERSION
	in.readByte();

	// POSITION
	_pos = in.readInt();

	// NO_ENTRY_VALUE
	no_entry_value = in.readChar();

	// ENTRIES
	int len = in.readInt();
	_data = new char[ len ];
	for( int i = 0; i < len; i++ ) {
		_data[ i ] = in.readChar();
	}
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:20,代码来源:TCharArrayList.java

示例10: readUTF

import java.io.ObjectInput; //导入依赖的package包/类
/**
 *
 * Reads in a string that has been encoded using a modified UTF-8  format. The general contract of readUTF  is
 * that it reads a representation of a Unicode character string encoded in modified UTF-8 format; this string of
 * characters is then returned as a String.
 *
 * First, four bytes are read (readInt) and used to construct an unsigned 16-bit integer in exactly the manner
 * of the readUnsignedShort  method . This integer value is called the UTF length and specifies the number of
 * additional bytes to be read. These bytes are then converted to characters by considering them in groups. The
 * length of each group is computed from the value of the first byte of the group. The byte following a group, if
 * any, is the first byte of the next group.
 *
 *See also {@link java.io.DataInput#readUTF()}.
 *
 * @param objectInput The objectInput to read from
 * @return The read string
 * @throws java.io.IOException If the value can't be read
 */
public static String readUTF( ObjectInput objectInput ) throws IOException
{
    // Read length of the string
    int strLength = objectInput.readInt();

    // Start reading the string
    StringBuilder strBuf = new StringBuilder( objectInput.readUTF() );

    if ( ( strLength == 0 ) && ( "null".equals( strBuf.toString() ) ) ) 
    {
        // The special case of a 'null' string
        return null;
    }
    else
    {
        while ( strLength > strBuf.length() )
        {
            strBuf.append( objectInput.readUTF() );
        }
        return strBuf.toString();
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:41,代码来源:Unicode.java

示例11: testSerialization

import java.io.ObjectInput; //导入依赖的package包/类
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    SimpleDialFrame f1 = new SimpleDialFrame();
    SimpleDialFrame f2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(f1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        f2 = (SimpleDialFrame) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(f1, f2);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:SimpleDialFrameTests.java

示例12: testSerialization

import java.io.ObjectInput; //导入依赖的package包/类
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    SignalRenderer r1 = new SignalRenderer();
    SignalRenderer r2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(r1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        r2 = (SignalRenderer) in.readObject();
        in.close();
    }
    catch (Exception e) {
        System.out.println(e.toString());
    }
    assertEquals(r1, r2);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:SignalRendererTests.java

示例13: readExternal

import java.io.ObjectInput; //导入依赖的package包/类
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
	iUniqueId = in.readLong();
	iInstructionalType = (String)in.readObject();
	iName = (String)in.readObject();
	
	int nrSections = in.readInt();
	iSections.clear();
	for (int i = 0; i < nrSections; i++)
		iSections.add(new XSection(in));
	
	iConfigId = in.readLong();
	iParentId = in.readLong();
	if (iParentId < 0) iParentId = null;
	
	iCredit = (in.readBoolean() ? new XCredit(in) : null);
	
	iAllowOverlap = in.readBoolean();
	
	int nrCredits = in.readInt();
	iCreditByCourse.clear();
	for (int i = 0; i < nrCredits; i++)
		iCreditByCourse.put(in.readLong(), new XCredit(in));
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:25,代码来源:XSubpart.java

示例14: readExternal

import java.io.ObjectInput; //导入依赖的package包/类
/** {@inheritDoc} */
public void readExternal(ObjectInput in)
        throws IOException, ClassNotFoundException {

    // VERSION
    in.readByte();

    // NO_ENTRY_VALUE
    no_entry_value = in.readByte();

    // ENTRIES
    int len = in.readInt();
    for (int i = 0; i < len; i++) {
        add(in.readByte());
    }
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:17,代码来源:TByteLinkedList.java

示例15: readExternal

import java.io.ObjectInput; //导入依赖的package包/类
@Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
    final int metaSize = in.readInt();
    Preconditions.checkArgument(metaSize >= 0, "Invalid negative metadata map length %s", metaSize);

    // Default pre-allocate is 4, which should be fine
    final Builder<Class<? extends ShardDataTreeSnapshotMetadata<?>>, ShardDataTreeSnapshotMetadata<?>>
            metaBuilder = ImmutableMap.builder();
    for (int i = 0; i < metaSize; ++i) {
        final ShardDataTreeSnapshotMetadata<?> m = (ShardDataTreeSnapshotMetadata<?>) in.readObject();
        if (m != null) {
            metaBuilder.put(m.getType(), m);
        } else {
            LOG.warn("Skipping null metadata");
        }
    }

    metadata = metaBuilder.build();
    rootNode = Verify.verifyNotNull(SerializationUtils.deserializeNormalizedNode(in));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:MetadataShardDataTreeSnapshot.java


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