本文整理匯總了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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
}
示例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");
}
}
示例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");
}
}
示例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;
}
示例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");
}
}
示例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);
}
}
示例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");
}
}
示例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");
}
示例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;
}
}
示例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;
}
示例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;
}
}