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


Java StreamCorruptedException类代码示例

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


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

示例1: readClassDescriptor

import java.io.StreamCorruptedException; //导入依赖的package包/类
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException,ClassNotFoundException
{
	int type = read();
	if( type < 0 )
		throw new EOFException();
	switch( type )
	{
		case 0:
			return super.readClassDescriptor();
		case 1:
			Class<?> clazz = loadClass(readUTF());
			return ObjectStreamClass.lookup(clazz);
		default:
			throw new StreamCorruptedException("Unexpected class descriptor type: " + type);
	}
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:18,代码来源:CompactedObjectInputStream.java

示例2: readObject

import java.io.StreamCorruptedException; //导入依赖的package包/类
public Object readObject() throws ClassNotFoundException, IOException {
    int objectSize = in.readInt();
    if (objectSize <= 0) {
        throw new StreamCorruptedException("Invalid objectSize: " + objectSize);
    }
    if (objectSize > maxObjectSize) {
        throw new StreamCorruptedException("ObjectSize too big: " + objectSize + " (expected: <= " + maxObjectSize
                + ')');
    }

    IoBuffer buf = IoBuffer.allocate(objectSize + 4, false);
    buf.putInt(objectSize);
    in.readFully(buf.array(), 4, objectSize);
    buf.position(0);
    buf.limit(objectSize + 4);

    return buf.getObject(classLoader);
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:ObjectSerializationInputStream.java

示例3: readVarLongUnsigned

import java.io.StreamCorruptedException; //导入依赖的package包/类
/**
 * Reads a value that was encoded via {@link #writeVarLongUnsigned(long, DataOutput)}.
 *
 * @param in Data input.
 *
 * @return Value.
 *
 * @throws IOException if failed to read value.
 */
// Code borrowed from 'stream-lib' (Apache 2.0 license) - see https://github.com/addthis/stream-lib
public static long readVarLongUnsigned(DataInput in) throws IOException {
    long value = 0L;
    int i = 0;
    long b;

    while (((b = in.readByte()) & 0x80L) != 0) {
        value |= (b & 0x7F) << i;

        i += 7;

        if (i > 63) {
            throw new StreamCorruptedException("Variable length size is too long");
        }
    }

    return value | b << i;
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:28,代码来源:CodecUtils.java

示例4: readVarIntUnsigned

import java.io.StreamCorruptedException; //导入依赖的package包/类
/**
 * Reads a value that was encoded via {@link #writeVarIntUnsigned(int, DataOutput)}.
 *
 * @param in Data input.
 *
 * @return Value.
 *
 * @throws IOException if failed to read value.
 */
// Code borrowed from 'stream-lib' (Apache 2.0 license) - see https://github.com/addthis/stream-lib
public static int readVarIntUnsigned(DataInput in) throws IOException {
    int value = 0;
    int i = 0;
    int b;

    while (((b = in.readByte()) & 0x80) != 0) {
        value |= (b & 0x7F) << i;

        i += 7;

        if (i > 35) {
            throw new StreamCorruptedException("Variable length size is too long");
        }
    }

    return value | b << i;
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:28,代码来源:CodecUtils.java

示例5: skipCustomUsingFVD

import java.io.StreamCorruptedException; //导入依赖的package包/类
private void skipCustomUsingFVD(ValueMember[] fields,
                                com.sun.org.omg.SendingContext.CodeBase sender)
                                throws InvalidClassException, StreamCorruptedException,
                                       ClassNotFoundException, IOException
{
    readFormatVersion();
    boolean calledDefaultWriteObject = readBoolean();

    if (calledDefaultWriteObject)
        throwAwayData(fields, sender);

    if (getStreamFormatVersion() == 2) {

        ((ValueInputStream)getOrbStream()).start_value();
        ((ValueInputStream)getOrbStream()).end_value();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:IIOPInputStream.java

示例6: readData

import java.io.StreamCorruptedException; //导入依赖的package包/类
public void readData(InputStreamHook stream) throws IOException {
    org.omg.CORBA.ORB orb = stream.getOrbStream().orb();
    if ((orb == null) ||
            !(orb instanceof com.sun.corba.se.spi.orb.ORB)) {
        throw new StreamCorruptedException(
                             "Default data must be read first");
    }
    ORBVersion clientOrbVersion =
        ((com.sun.corba.se.spi.orb.ORB)orb).getORBVersion();

    // Fix Date interop bug. For older versions of the ORB don't do
    // anything for readData(). Before this used to throw
    // StreamCorruptedException for older versions of the ORB where
    // calledDefaultWriteObject always returns true.
    if ((ORBVersionFactory.getPEORB().compareTo(clientOrbVersion) <= 0) ||
            (clientOrbVersion.equals(ORBVersionFactory.getFOREIGN()))) {
        // XXX I18N and logging needed.
        throw new StreamCorruptedException("Default data must be read first");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:InputStreamHook.java

示例7: readInternal

import java.io.StreamCorruptedException; //导入依赖的package包/类
private static Object readInternal(byte type, ObjectInput in) throws IOException, ClassNotFoundException {
    switch (type) {
        case DURATION_TYPE: return Duration.readExternal(in);
        case INSTANT_TYPE: return Instant.readExternal(in);
        case LOCAL_DATE_TYPE: return LocalDate.readExternal(in);
        case LOCAL_DATE_TIME_TYPE: return LocalDateTime.readExternal(in);
        case LOCAL_TIME_TYPE: return LocalTime.readExternal(in);
        case ZONE_DATE_TIME_TYPE: return ZonedDateTime.readExternal(in);
        case ZONE_OFFSET_TYPE: return ZoneOffset.readExternal(in);
        case ZONE_REGION_TYPE: return ZoneRegion.readExternal(in);
        case OFFSET_TIME_TYPE: return OffsetTime.readExternal(in);
        case OFFSET_DATE_TIME_TYPE: return OffsetDateTime.readExternal(in);
        case YEAR_TYPE: return Year.readExternal(in);
        case YEAR_MONTH_TYPE: return YearMonth.readExternal(in);
        case MONTH_DAY_TYPE: return MonthDay.readExternal(in);
        case PERIOD_TYPE: return Period.readExternal(in);
        default:
            throw new StreamCorruptedException("Unknown serialized type");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:Ser.java

示例8: getResultStream

import java.io.StreamCorruptedException; //导入依赖的package包/类
/**
 * Returns an output stream (may put out header information
 * relating to the success of the call).
 * @param success If true, indicates normal return, else indicates
 * exceptional return.
 * @exception StreamCorruptedException If result stream previously
 * acquired
 * @exception IOException For any other problem with I/O.
 */
public ObjectOutput getResultStream(boolean success) throws IOException {
    /* make sure result code only marshaled once. */
    if (resultStarted)
        throw new StreamCorruptedException("result already in progress");
    else
        resultStarted = true;

    // write out return header
    // return header, part 1 (read by Transport)
    DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
    wr.writeByte(TransportConstants.Return);// transport op
    getOutputStream(true);  // creates a MarshalOutputStream
    // return header, part 2 (read by client-side RemoteCall)
    if (success)            //
        out.writeByte(TransportConstants.NormalReturn);
    else
        out.writeByte(TransportConstants.ExceptionalReturn);
    out.writeID();          // write id for gcAck
    return out;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:StreamRemoteCall.java

示例9: invokeObjectReader

import java.io.StreamCorruptedException; //导入依赖的package包/类
private boolean invokeObjectReader(ObjectStreamClass osc, Object obj, Class aclass)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IOException
{
    try {
        return osc.invokeReadObject( obj, this ) ;
    } catch (InvocationTargetException e) {
        Throwable t = e.getTargetException();
        if (t instanceof ClassNotFoundException)
            throw (ClassNotFoundException)t;
        else if (t instanceof IOException)
            throw (IOException)t;
        else if (t instanceof RuntimeException)
            throw (RuntimeException) t;
        else if (t instanceof Error)
            throw (Error) t;
        else
            // XXX I18N, logging needed.
            throw new Error("internal error");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:IIOPInputStream.java

示例10: readHashtable

import java.io.StreamCorruptedException; //导入依赖的package包/类
@Override
void readHashtable(ObjectInputStream s) throws IOException,
        ClassNotFoundException {
    // Read in the threshold and loadfactor
    s.defaultReadObject();

    // Read the original length of the array and number of elements
    int origlength = s.readInt();
    int elements = s.readInt();

    // Validate # of elements
    if (elements < 0) {
        throw new StreamCorruptedException("Illegal # of Elements: " + elements);
    }

    // create CHM of appropriate capacity
    map = new ConcurrentHashMap<>(elements);

    // Read all the key/value objects
    for (; elements > 0; elements--) {
        Object key = s.readObject();
        Object value = s.readObject();
        map.put(key, value);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:Properties.java

示例11: readEnum

import java.io.StreamCorruptedException; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
	private final Object readEnum() throws IOException {
		final Class<?> c = readEnumType();
		final String id = readEnumID();
		if (Enum.class.isAssignableFrom(c)) {
			return Yggdrasil.getEnumConstant((Class) c, id);
		} else if (PseudoEnum.class.isAssignableFrom(c)) {
			final Object o = PseudoEnum.valueOf((Class) c, id);
			if (o != null)
				return o;
//			if (YggdrasilRobustPseudoEnum.class.isAssignableFrom(c)) {
//				// TODO create this and a handler (for Enums as well)
//			}
			throw new StreamCorruptedException("Enum constant " + id + " does not exist in " + c);
		} else {
			throw new StreamCorruptedException(c + " is not an enum type");
		}
	}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:19,代码来源:YggdrasilInputStream.java

示例12: readExternal

import java.io.StreamCorruptedException; //导入依赖的package包/类
public void readExternal(ObjectInput in) 
	throws IOException,ClassNotFoundException
	{
//MsgTrace.traceString("{{{tu.readExternal");
		try
		{
			tid = (GlobalTransactionId)in.readObject();
			tranSeq = in.readInt();
			recordSeq = in.readInt();
			removeWhat = in.readInt();
			LWMTranSeq = in.readInt();
			rollBack = in.readBoolean();
			lastRecord = in.readInt();
			lastTransaction = in.readBoolean();
			optionalDataLen = in.readInt();
		}

		catch ( ClassCastException exception ) {
//MsgTrace.traceString("{{{tu.readExternal---exception");
			throw new StreamCorruptedException();
		}
//MsgTrace.traceString("}}}tu.readExternal");
	}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:24,代码来源:T_Undoable.java

示例13: excessiveField

import java.io.StreamCorruptedException; //导入依赖的package包/类
@Override
public boolean excessiveField(@NonNull final FieldContext field) throws StreamCorruptedException {
	if (field.getID().equals("mod")) {
		final double[] mod = field.getObject(double[].class);
		if (mod == null)
			return true;
		if (mod.length != 3)
			throw new StreamCorruptedException();
		set("pitchOrX", mod[0]);
		set("yawOrY", mod[1]);
		set("lengthOrZ", mod[1]);
		return true;
	} else if (field.getID().equals("pitch")) {
		set("pitchOrX", field.getPrimitive(double.class));
		return true;
	} else if (field.getID().equals("yaw")) {
		set("yawOrY", field.getPrimitive(double.class));
		return true;
	} else if (field.getID().equals("length")) {
		set("lengthOrZ", field.getPrimitive(double.class));
		return true;
	} else {
		return false;
	}
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:26,代码来源:Direction.java

示例14: byteArrayToObject

import java.io.StreamCorruptedException; //导入依赖的package包/类
public static Object byteArrayToObject(byte[] bytes)
    throws StreamCorruptedException, IOException, ClassNotFoundException {
  Object obj = null;
  ByteArrayInputStream bis = null;
  ObjectInputStream ois = null;
  try {
    bis = new ByteArrayInputStream(bytes);
    ois = new ObjectInputStream(bis);
    obj = ois.readObject();
  } finally {
    if (bis != null) {
      bis.close();
    }
    if (ois != null) {
      ois.close();
    }
  }
  return obj;
}
 
开发者ID:RapidProjectH2020,项目名称:offloading-framework-android,代码行数:20,代码来源:Utils.java

示例15: setField

import java.io.StreamCorruptedException; //导入依赖的package包/类
public void setField(final Object o, final Field f, final Yggdrasil y) throws StreamCorruptedException {
	if (Modifier.isStatic(f.getModifiers()))
		throw new StreamCorruptedException("The field " + id + " of " + f.getDeclaringClass() + " is static");
	if (Modifier.isTransient(f.getModifiers()))
		throw new StreamCorruptedException("The field " + id + " of " + f.getDeclaringClass() + " is transient");
	if (f.getType().isPrimitive() != isPrimitiveValue)
		throw new StreamCorruptedException("The field " + id + " of " + f.getDeclaringClass() + " is " + (f.getType().isPrimitive() ? "" : "not ") + "primitive");
	try {
		f.setAccessible(true);
		f.set(o, value);
	} catch (final IllegalArgumentException e) {
		if (!(o instanceof YggdrasilRobustSerializable) || !((YggdrasilRobustSerializable) o).incompatibleField(f, this))
			y.incompatibleField(o, f, this);
	} catch (final IllegalAccessException e) {
		assert false;
	}
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:18,代码来源:Fields.java


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