Java Code Examples for java.io.DataOutputStream#writeByte()
The following examples show how to use
java.io.DataOutputStream#writeByte() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProxyGenerator.java From HotswapAgent with GNU General Public License v2.0 | 5 votes |
private MethodInfo generateStaticInitializerCaller() throws IOException { MethodInfo minfo = new MethodInfo("<clinit>", "()V", ACC_STATIC); DataOutputStream out = new DataOutputStream(minfo.code); out.writeByte(opc_invokestatic); out.writeShort(cp.getMethodRef(dotToSlash(className), initMethodName, "()V")); out.writeByte(opc_return); minfo.declaredExceptions = new short[0]; return minfo; }
Example 2
Source File: DataAuthPlan.java From incubator-iotdb with Apache License 2.0 | 5 votes |
@Override public void serialize(DataOutputStream stream) throws IOException { int type = this.getPlanType(super.getOperatorType()); stream.writeByte((byte) type); stream.writeInt(users.size()); for (String user : users) { putString(stream, user); } }
Example 3
Source File: DHTPluginStorageManager.java From TorrentEngine with GNU General Public License v3.0 | 5 votes |
public void serialiseStats( storageKey key, DataOutputStream dos ) throws IOException { dos.writeByte( (byte)0 ); // version dos.writeInt( key.getEntryCount()); dos.writeInt( key.getSize()); dos.writeInt( key.getReadsPerMinute()); dos.writeByte( key.getDiversificationType()); }
Example 4
Source File: JSR_W.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Dump instruction as byte code to stream out. * @param out Output stream */ @Override public void dump( final DataOutputStream out ) throws IOException { super.setIndex(getTargetOffset()); out.writeByte(super.getOpcode()); out.writeInt(super.getIndex()); }
Example 5
Source File: PersistentMap.java From bazel with Apache License 2.0 | 5 votes |
/** * Writes the Map entries to the specified DataOutputStream. * * @param out the DataOutputStream to write the Map entries to. * @param map the Map containing the entries to be written to the * DataOutputStream. * @throws IOException */ private void writeEntries(DataOutputStream out, Map<K, V> map) throws IOException { for (Map.Entry<K, V> entry : map.entrySet()) { out.writeByte(ENTRY_MAGIC); writeKey(entry.getKey(), out); V value = entry.getValue(); boolean isEntry = (value != null); out.writeBoolean(isEntry); if (isEntry) { writeValue(value, out); } } }
Example 6
Source File: MouseEventPacket.java From cloudstack with Apache License 2.0 | 5 votes |
@Override public void write(DataOutputStream os) throws IOException { os.writeByte(RfbConstants.CLIENT_POINTER_EVENT); os.writeByte(buttonMask); os.writeShort(x); os.writeShort(y); }
Example 7
Source File: JSR.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Dump instruction as byte code to stream out. * @param out Output stream */ @Override public void dump( final DataOutputStream out ) throws IOException { super.setIndex(getTargetOffset()); if (super.getOpcode() == com.sun.org.apache.bcel.internal.Const.JSR) { super.dump(out); } else { // JSR_W super.setIndex(getTargetOffset()); out.writeByte(super.getOpcode()); out.writeInt(super.getIndex()); } }
Example 8
Source File: CiphertextHeaders.java From aws-encryption-sdk-java with Apache License 2.0 | 5 votes |
/** * Serialize the header fields into a byte array. Note this method does not * serialize the header nonce and tag. * * @return * the serialized bytes of the header fields not including the * header nonce and tag. */ public byte[] serializeAuthenticatedFields() { try { ByteArrayOutputStream outBytes = new ByteArrayOutputStream(); DataOutputStream dataStream = new DataOutputStream(outBytes); dataStream.writeByte(version_); dataStream.writeByte(typeVal_); dataStream.writeShort(cryptoAlgoVal_); dataStream.write(messageId_); PrimitivesParser.writeUnsignedShort(dataStream, encryptionContextLen_); if (encryptionContextLen_ > 0) { dataStream.write(encryptionContext_); } dataStream.writeShort(cipherKeyCount_); for (int i = 0; i < cipherKeyCount_; i++) { final byte[] cipherKeyBlobBytes = cipherKeyBlobs_.get(i).toByteArray(); dataStream.write(cipherKeyBlobBytes); } dataStream.writeByte(contentTypeVal_); dataStream.writeInt(reservedField_); dataStream.writeByte(nonceLen_); dataStream.writeInt(frameLength_); dataStream.close(); return outBytes.toByteArray(); } catch (IOException e) { throw new RuntimeException("Failed to serialize cipher text headers", e); } }
Example 9
Source File: Nbt.java From mapwriter with MIT License | 5 votes |
public void writeElement(DataOutputStream dos) throws IOException{ dos.writeByte(this.tagID); if (this.tagID != TAG_END) { dos.writeUTF(this.name); this.writeElementData(dos); } }
Example 10
Source File: SavepointV2Serializer.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@VisibleForTesting public static void serializeOperatorStateHandle( OperatorStateHandle stateHandle, DataOutputStream dos) throws IOException { if (stateHandle != null) { dos.writeByte(PARTITIONABLE_OPERATOR_STATE_HANDLE); Map<String, OperatorStateHandle.StateMetaInfo> partitionOffsetsMap = stateHandle.getStateNameToPartitionOffsets(); dos.writeInt(partitionOffsetsMap.size()); for (Map.Entry<String, OperatorStateHandle.StateMetaInfo> entry : partitionOffsetsMap.entrySet()) { dos.writeUTF(entry.getKey()); OperatorStateHandle.StateMetaInfo stateMetaInfo = entry.getValue(); int mode = stateMetaInfo.getDistributionMode().ordinal(); dos.writeByte(mode); long[] offsets = stateMetaInfo.getOffsets(); dos.writeInt(offsets.length); for (long offset : offsets) { dos.writeLong(offset); } } serializeStreamStateHandle(stateHandle.getDelegateStateHandle(), dos); } else { dos.writeByte(NULL_HANDLE); } }
Example 11
Source File: MapCreatorBase.java From brouter with MIT License | 5 votes |
protected static void writeId( DataOutputStream o, long id ) throws IOException { if ( id == -1 ) { o.writeByte( 32 ); return; } int offset = (int)( id & 0x1f ); int i = (int)( id >> 5 ); o.writeByte( offset ); o.writeInt( i ); }
Example 12
Source File: TIFFWriter.java From beast-mcmc with GNU Lesser General Public License v2.1 | 5 votes |
static void fputword(DataOutputStream dataOut, short n) { try { dataOut.writeByte((byte) n); dataOut.writeByte((byte) (n >> 8)); } catch (java.io.IOException read) { System.out.println("Error occured while writing output file."); } }
Example 13
Source File: ProxyGenerator.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Generate code to invoke the Class.forName with the name of the given * class to get its Class object at runtime. The code is written to * the supplied stream. Note that the code generated by this method * may caused the checked ClassNotFoundException to be thrown. */ private void codeClassForName(Class<?> cl, DataOutputStream out) throws IOException { code_ldc(cp.getString(cl.getName()), out); out.writeByte(opc_invokestatic); out.writeShort(cp.getMethodRef( "java/lang/Class", "forName", "(Ljava/lang/String;)Ljava/lang/Class;")); }
Example 14
Source File: PrivateCellUtil.java From hbase with Apache License 2.0 | 5 votes |
/** * Write rowkey excluding the common part. * @param cell * @param rLen * @param commonPrefix * @param out * @throws IOException */ public static void writeRowKeyExcludingCommon(Cell cell, short rLen, int commonPrefix, DataOutputStream out) throws IOException { if (commonPrefix == 0) { out.writeShort(rLen); } else if (commonPrefix == 1) { out.writeByte((byte) rLen); commonPrefix--; } else { commonPrefix -= KeyValue.ROW_LENGTH_SIZE; } if (rLen > commonPrefix) { writeRowSkippingBytes(out, cell, rLen, commonPrefix); } }
Example 15
Source File: ProxyGenerator.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
/** * Generate code for initializing the static field that stores * the Method object for this proxy method. The code is written * to the supplied stream. */ private void codeFieldInitialization(DataOutputStream out) throws IOException { codeClassForName(fromClass, out); code_ldc(cp.getString(methodName), out); code_ipush(parameterTypes.length, out); out.writeByte(opc_anewarray); out.writeShort(cp.getClass("java/lang/Class")); for (int i = 0; i < parameterTypes.length; i++) { out.writeByte(opc_dup); code_ipush(i, out); if (parameterTypes[i].isPrimitive()) { PrimitiveTypeInfo prim = PrimitiveTypeInfo.get(parameterTypes[i]); out.writeByte(opc_getstatic); out.writeShort(cp.getFieldRef( prim.wrapperClassName, "TYPE", "Ljava/lang/Class;")); } else { codeClassForName(parameterTypes[i], out); } out.writeByte(opc_aastore); } out.writeByte(opc_invokevirtual); out.writeShort(cp.getMethodRef( "java/lang/Class", "getMethod", "(Ljava/lang/String;[Ljava/lang/Class;)" + "Ljava/lang/reflect/Method;")); out.writeByte(opc_putstatic); out.writeShort(cp.getFieldRef( dotToSlash(className), methodFieldName, "Ljava/lang/reflect/Method;")); }
Example 16
Source File: JRMPListener.java From ysoserial-modified with MIT License | 4 votes |
private void doCall ( DataInputStream in, DataOutputStream out, Object payload ) throws Exception { ObjectInputStream ois = new ObjectInputStream(in) { @Override protected Class<?> resolveClass ( ObjectStreamClass desc ) throws IOException, ClassNotFoundException { if ( "[Ljava.rmi.server.ObjID;".equals(desc.getName())) { return ObjID[].class; } else if ("java.rmi.server.ObjID".equals(desc.getName())) { return ObjID.class; } else if ( "java.rmi.server.UID".equals(desc.getName())) { return UID.class; } throw new IOException("Not allowed to read object"); } }; ObjID read; try { read = ObjID.read(ois); } catch ( java.io.IOException e ) { throw new MarshalException("unable to read objID", e); } if ( read.hashCode() == 2 ) { ois.readInt(); // method ois.readLong(); // hash System.err.println("Is DGC call for " + Arrays.toString((ObjID[])ois.readObject())); } System.err.println("Sending return with payload for obj " + read); out.writeByte(TransportConstants.Return);// transport op ObjectOutputStream oos = new JRMPClient.MarshalOutputStream(out, this.classpathUrl); oos.writeByte(TransportConstants.ExceptionalReturn); new UID().write(oos); BadAttributeValueExpException ex = new BadAttributeValueExpException(null); Reflections.setFieldValue(ex, "val", payload); oos.writeObject(ex); oos.flush(); out.flush(); this.hadConnection = true; synchronized ( this.waitLock ) { this.waitLock.notifyAll(); } }
Example 17
Source File: LDC2_W.java From awacs with Apache License 2.0 | 4 votes |
public void writeToStream(DataOutputStream out, int offset) throws IOException { out.writeByte(opc_ldc2_w); out.writeShort(getOperand(0)); }
Example 18
Source File: ProxyGenerator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Generate the static initializer method for the proxy class. */ private MethodInfo generateStaticInitializer() throws IOException { MethodInfo minfo = new MethodInfo( "<clinit>", "()V", ACC_STATIC); int localSlot0 = 1; short pc, tryBegin = 0, tryEnd; DataOutputStream out = new DataOutputStream(minfo.code); for (List<ProxyMethod> sigmethods : proxyMethods.values()) { for (ProxyMethod pm : sigmethods) { pm.codeFieldInitialization(out); } } out.writeByte(opc_return); tryEnd = pc = (short) minfo.code.size(); minfo.exceptionTable.add(new ExceptionTableEntry( tryBegin, tryEnd, pc, cp.getClass("java/lang/NoSuchMethodException"))); code_astore(localSlot0, out); out.writeByte(opc_new); out.writeShort(cp.getClass("java/lang/NoSuchMethodError")); out.writeByte(opc_dup); code_aload(localSlot0, out); out.writeByte(opc_invokevirtual); out.writeShort(cp.getMethodRef( "java/lang/Throwable", "getMessage", "()Ljava/lang/String;")); out.writeByte(opc_invokespecial); out.writeShort(cp.getMethodRef( "java/lang/NoSuchMethodError", "<init>", "(Ljava/lang/String;)V")); out.writeByte(opc_athrow); pc = (short) minfo.code.size(); minfo.exceptionTable.add(new ExceptionTableEntry( tryBegin, tryEnd, pc, cp.getClass("java/lang/ClassNotFoundException"))); code_astore(localSlot0, out); out.writeByte(opc_new); out.writeShort(cp.getClass("java/lang/NoClassDefFoundError")); out.writeByte(opc_dup); code_aload(localSlot0, out); out.writeByte(opc_invokevirtual); out.writeShort(cp.getMethodRef( "java/lang/Throwable", "getMessage", "()Ljava/lang/String;")); out.writeByte(opc_invokespecial); out.writeShort(cp.getMethodRef( "java/lang/NoClassDefFoundError", "<init>", "(Ljava/lang/String;)V")); out.writeByte(opc_athrow); if (minfo.code.size() > 65535) { throw new IllegalArgumentException("code size limit exceeded"); } minfo.maxStack = 10; minfo.maxLocals = (short) (localSlot0 + 1); minfo.declaredExceptions = new short[0]; return minfo; }
Example 19
Source File: ProxyGenerator.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Generate code for initializing the static field that stores * the Method object for this proxy method. The code is written * to the supplied stream. */ private void codeFieldInitialization(DataOutputStream out) throws IOException { codeClassForName(fromClass, out); code_ldc(cp.getString(methodName), out); code_ipush(parameterTypes.length, out); out.writeByte(opc_anewarray); out.writeShort(cp.getClass("java/lang/Class")); for (int i = 0; i < parameterTypes.length; i++) { out.writeByte(opc_dup); code_ipush(i, out); if (parameterTypes[i].isPrimitive()) { PrimitiveTypeInfo prim = PrimitiveTypeInfo.get(parameterTypes[i]); out.writeByte(opc_getstatic); out.writeShort(cp.getFieldRef( prim.wrapperClassName, "TYPE", "Ljava/lang/Class;")); } else { codeClassForName(parameterTypes[i], out); } out.writeByte(opc_aastore); } out.writeByte(opc_invokevirtual); out.writeShort(cp.getMethodRef( "java/lang/Class", "getMethod", "(Ljava/lang/String;[Ljava/lang/Class;)" + "Ljava/lang/reflect/Method;")); out.writeByte(opc_putstatic); out.writeShort(cp.getFieldRef( dotToSlash(className), methodFieldName, "Ljava/lang/reflect/Method;")); }
Example 20
Source File: ConstantString.java From Bytecoder with Apache License 2.0 | 2 votes |
/** * Dump constant field reference to file stream in binary format. * * @param file Output file stream * @throws IOException */ @Override public final void dump( final DataOutputStream file ) throws IOException { file.writeByte(super.getTag()); file.writeShort(string_index); }