本文整理汇总了Java中java.io.DataOutputStream.writeByte方法的典型用法代码示例。如果您正苦于以下问题:Java DataOutputStream.writeByte方法的具体用法?Java DataOutputStream.writeByte怎么用?Java DataOutputStream.writeByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.DataOutputStream
的用法示例。
在下文中一共展示了DataOutputStream.writeByte方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDataTypeShouldReturnUnknownIfPDXTypeIsNull
import java.io.DataOutputStream; //导入方法依赖的package包/类
@Test
public void getDataTypeShouldReturnUnknownIfPDXTypeIsNull() throws IOException {
int somePdxTypeInt = 1;
PdxType somePdxType = null;
TypeRegistry mockTypeRegistry = mock(TypeRegistry.class);
when(mockTypeRegistry.getType(somePdxTypeInt)).thenReturn(somePdxType);
GemFireCacheImpl pdxInstance = mock(GemFireCacheImpl.class);
when(pdxInstance.getPdxRegistry()).thenReturn(mockTypeRegistry);
PowerMockito.mockStatic(GemFireCacheImpl.class);
when(GemFireCacheImpl
.getForPdx("PDX registry is unavailable because the Cache has been closed."))
.thenReturn(pdxInstance);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(baos);
out.writeByte(DSCODE.PDX);
out.writeInt(somePdxTypeInt);
byte[] bytes = baos.toByteArray();
String type = DataType.getDataType(bytes);
assertThat(type).isEqualTo("org.apache.geode.pdx.PdxInstance: unknown id=" + somePdxTypeInt);
}
示例2: doMessage
import java.io.DataOutputStream; //导入方法依赖的package包/类
private void doMessage ( Socket s, DataInputStream in, DataOutputStream out, Object payload ) throws Exception {
System.err.println("Reading message...");
int op = in.read();
switch ( op ) {
case TransportConstants.Call:
// service incoming RMI call
doCall(in, out, payload);
break;
case TransportConstants.Ping:
// send ack for ping
out.writeByte(TransportConstants.PingAck);
break;
case TransportConstants.DGCAck:
UID u = UID.read(in);
break;
default:
throw new IOException("unknown transport op " + op);
}
s.close();
}
示例3: codeWrapArgument
import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
* Generate code for wrapping an argument of the given type
* whose value can be found at the specified local variable
* index, in order for it to be passed (as an Object) to the
* invocation handler's "invoke" method. The code is written
* to the supplied stream.
*/
private void codeWrapArgument(Class<?> type, int slot,
DataOutputStream out)
throws IOException
{
if (type.isPrimitive()) {
PrimitiveTypeInfo prim = PrimitiveTypeInfo.get(type);
if (type == int.class ||
type == boolean.class ||
type == byte.class ||
type == char.class ||
type == short.class)
{
code_iload(slot, out);
} else if (type == long.class) {
code_lload(slot, out);
} else if (type == float.class) {
code_fload(slot, out);
} else if (type == double.class) {
code_dload(slot, out);
} else {
throw new AssertionError();
}
out.writeByte(opc_invokestatic);
out.writeShort(cp.getMethodRef(
prim.wrapperClassName,
"valueOf", prim.wrapperValueOfDesc));
} else {
code_aload(slot, out);
}
}
示例4: writeFlatKey
import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
* Writes the Cell's key part as it would have serialized in a KeyValue. The format is <2 bytes
* rk len><rk><1 byte cf len><cf><qualifier><8 bytes
* timestamp><1 byte type>
* @param cell
* @param out
* @throws IOException
*/
public static void writeFlatKey(Cell cell, DataOutputStream out) throws IOException {
short rowLen = cell.getRowLength();
out.writeShort(rowLen);
out.write(cell.getRowArray(), cell.getRowOffset(), rowLen);
byte fLen = cell.getFamilyLength();
out.writeByte(fLen);
out.write(cell.getFamilyArray(), cell.getFamilyOffset(), fLen);
out.write(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
out.writeLong(cell.getTimestamp());
out.writeByte(cell.getTypeByte());
}
示例5: postSerialise
import java.io.DataOutputStream; //导入方法依赖的package包/类
protected void
postSerialise(
DataOutputStream os )
throws IOException
{
if ( protocol_version < DHTTransportUDP.PROTOCOL_VERSION_FIX_ORIGINATOR ){
// originator version is at tail so it works with older versions
os.writeByte( getTransport().getProtocolVersion());
}
}
示例6: dump
import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void dump(final DataOutputStream dos) throws IOException
{
super.dump(dos);
dos.writeByte(parameter_annotation_table.length);
for (final ParameterAnnotationEntry element : parameter_annotation_table) {
element.dump(dos);
}
}
示例7: codeUnwrapReturnValue
import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
* Generate code for unwrapping a return value of the given
* type from the invocation handler's "invoke" method (as type
* Object) to its correct type. The code is written to the
* supplied stream.
*/
private void codeUnwrapReturnValue(Class<?> type, DataOutputStream out)
throws IOException
{
if (type.isPrimitive()) {
PrimitiveTypeInfo prim = PrimitiveTypeInfo.get(type);
out.writeByte(opc_checkcast);
out.writeShort(cp.getClass(prim.wrapperClassName));
out.writeByte(opc_invokevirtual);
out.writeShort(cp.getMethodRef(
prim.wrapperClassName,
prim.unwrapMethodName, prim.unwrapMethodDesc));
if (type == int.class ||
type == boolean.class ||
type == byte.class ||
type == char.class ||
type == short.class)
{
out.writeByte(opc_ireturn);
} else if (type == long.class) {
out.writeByte(opc_lreturn);
} else if (type == float.class) {
out.writeByte(opc_freturn);
} else if (type == double.class) {
out.writeByte(opc_dreturn);
} else {
throw new AssertionError();
}
} else {
out.writeByte(opc_checkcast);
out.writeShort(cp.getClass(dotToSlash(type.getName())));
out.writeByte(opc_areturn);
}
}
示例8: send
import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void send(DataOutputStream out) throws IOException {
byte[] packetId = VarData.getVarInt(0x23);
byte[] levelType = VarData.packString(this.levelType.getId());
VarData.writeVarInt(out, 12 + levelType.length + packetId.length);
out.write(packetId);
out.writeInt(entityID);
out.writeByte(gamemode.getId());
out.writeInt(dimensionType.getId());
out.writeByte(difficulty.getId());
out.writeByte(maxPlayers);
out.write(levelType);
out.writeBoolean(reducedDebug);
out.flush();
}
示例9: save
import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void save(DataOutputStream out) throws Exception
{
out.writeChar(letter);
out.writeByte(isAcceptNode ? 1 : 0);
out.writeInt(transitionSetBeginIndex);
out.writeInt(transitionSetSize);
}
示例10: dump
import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
* Dump instruction as byte code to stream out.
* @param out Output stream
*/
@Override
public void dump( final DataOutputStream out ) throws IOException {
out.writeByte(super.getOpcode());
out.writeShort(super.getIndex());
out.writeByte(nargs);
out.writeByte(0);
}
示例11: dump
import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
* Dump instruction as byte code to stream out.
*
* @param out Output stream
*/
@Override
public void dump(final DataOutputStream out) throws IOException {
out.writeByte(super.getOpcode());
for (int i = 0; i < padding; i++) {
out.writeByte(0);
}
super.setIndex(getTargetOffset()); // Write default target offset
out.writeInt(super.getIndex());
}
示例12: dump
import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
* Dump instruction as byte code to stream out.
* @param out Output stream
*/
@Override
public void dump( final DataOutputStream out ) throws IOException {
if (wide) {
out.writeByte(com.sun.org.apache.bcel.internal.Const.WIDE);
}
out.writeByte(super.getOpcode());
if (wide) {
out.writeShort(index);
} else {
out.writeByte(index);
}
}
示例13: write
import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
* Write the constant to the output stream
*/
void write(Environment env, DataOutputStream out, ConstantPool tab) throws IOException {
out.writeByte(CONSTANT_NAMEANDTYPE);
out.writeShort(tab.index(name));
out.writeShort(tab.index(type));
}
示例14: write
import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
* Write the constant to the output stream
*/
void write(Environment env, DataOutputStream out, ConstantPool tab) throws IOException {
out.writeByte(CONSTANT_CLASS);
out.writeShort(tab.index(name));
}
示例15: dump
import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
* Dump instruction as byte code to stream out.
*/
@Override
public void dump(final DataOutputStream out) throws IOException {
super.dump(out);
out.writeByte(b);
}