本文整理汇总了Java中java.io.DataOutputStream.writeShort方法的典型用法代码示例。如果您正苦于以下问题:Java DataOutputStream.writeShort方法的具体用法?Java DataOutputStream.writeShort怎么用?Java DataOutputStream.writeShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.DataOutputStream
的用法示例。
在下文中一共展示了DataOutputStream.writeShort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeData
import java.io.DataOutputStream; //导入方法依赖的package包/类
private void initializeData(DataOutputStream out) throws IOException {
/* Write out various test values NORMALLY */
out.write(new byte[] { -100, 100 });
out.writeBoolean(true);
out.writeBoolean(false);
out.writeByte(100);
out.writeByte(-100);
out.writeByte((byte) 200);
out.writeChar('a');
out.writeShort((short) -30000);
out.writeShort((short) 50000);
out.writeInt(0xCAFEBABE);
out.writeLong(0xDEADBEEFCAFEBABEL);
out.writeUTF("Herby Derby");
out.writeFloat(Float.intBitsToFloat(0xCAFEBABE));
out.writeDouble(Double.longBitsToDouble(0xDEADBEEFCAFEBABEL));
}
示例2: generateConstructor
import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
* Generate the constructor method for the proxy class.
*/
private MethodInfo generateConstructor() throws IOException {
MethodInfo minfo = new MethodInfo(
"<init>", "(Ljava/lang/reflect/InvocationHandler;)V",
ACC_PUBLIC);
DataOutputStream out = new DataOutputStream(minfo.code);
code_aload(0, out);
code_aload(1, out);
out.writeByte(opc_invokespecial);
out.writeShort(cp.getMethodRef(
superclassName,
"<init>", "(Ljava/lang/reflect/InvocationHandler;)V"));
out.writeByte(opc_return);
minfo.maxStack = 10;
minfo.maxLocals = 2;
minfo.declaredExceptions = new short[0];
return minfo;
}
示例3: write
import java.io.DataOutputStream; //导入方法依赖的package包/类
static void write(BinaryAttribute attributes, DataOutputStream out,
BinaryConstantPool cpool, Environment env) throws IOException {
// count the number of attributes
int attributeCount = 0;
for (BinaryAttribute att = attributes; att != null; att = att.next)
attributeCount++;
out.writeShort(attributeCount);
// write out each attribute
for (BinaryAttribute att = attributes; att != null; att = att.next) {
Identifier name = att.name;
byte data[] = att.data;
// write the identifier
out.writeShort(cpool.indexString(name.toString(), env));
// write the length
out.writeInt(data.length);
// write the data
out.write(data, 0, data.length);
}
}
示例4: write
import java.io.DataOutputStream; //导入方法依赖的package包/类
public void write(DataOutputStream out) throws IOException {
out.writeByte(tag);
out.writeShort(index0);
/*
* If this entry type contains two indexes, write
* out the second, too.
*/
if (tag == CONSTANT_FIELD ||
tag == CONSTANT_METHOD ||
tag == CONSTANT_INTERFACEMETHOD ||
tag == CONSTANT_NAMEANDTYPE)
{
out.writeShort(index1);
}
}
示例5: write
import java.io.DataOutputStream; //导入方法依赖的package包/类
public void write(DataOutputStream paramDataOutputStream, ConstantPool paramConstantPool) throws IOException {
this.iMethodsCount = this.methodsVect.size();
paramDataOutputStream.writeShort(this.iMethodsCount);
for (int i = 0; i < this.iMethodsCount; i++) {
MethodInfo localMethodInfo = (MethodInfo) this.methodsVect.elementAt(i);
localMethodInfo.write(paramDataOutputStream, paramConstantPool);
}
}
示例6: dump
import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void dump(final DataOutputStream dos) throws IOException
{
dos.writeByte(super.getElementValueType()); // u1 type of value (ENUM_CONSTANT == 'e')
dos.writeShort(typeIdx); // u2
dos.writeShort(valueIdx); // u2
}
示例7: dump
import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
* Dump object to file stream in binary format.
*
* @param file Output file stream
* @throws IOException
*/
public final void dump(final DataOutputStream file) throws IOException {
file.writeShort(bootstrap_method_ref);
file.writeShort(bootstrap_arguments.length);
for (final int bootstrap_argument : bootstrap_arguments) {
file.writeShort(bootstrap_argument);
}
}
示例8: codeClassForName
import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
* 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;"));
}
示例9: codeClassForName
import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
* 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;"));
}
示例10: write_ieee_extended
import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
* Extended precision IEEE floating-point conversion routine.
* @argument DataOutputStream
* @argument double
* @exception IOException
*/
private void write_ieee_extended(DataOutputStream dos, float f) throws IOException {
/* The special cases NaN, Infinity and Zero are ignored, since
they do not represent useful sample rates anyway.
Denormalized number aren't handled, too. Below, there is a cast
from float to double. We hope that in this conversion,
numbers are normalized. Numbers that cannot be normalized are
ignored, too, as they, too, do not represent useful sample rates. */
long doubleBits = Double.doubleToLongBits((double) f);
long sign = (doubleBits & DOUBLE_SIGN_MASK)
>> (DOUBLE_EXPONENT_LENGTH + DOUBLE_MANTISSA_LENGTH);
long doubleExponent = (doubleBits & DOUBLE_EXPONENT_MASK)
>> DOUBLE_MANTISSA_LENGTH;
long doubleMantissa = doubleBits & DOUBLE_MANTISSA_MASK;
long extendedExponent = doubleExponent - DOUBLE_EXPONENT_OFFSET
+ EXTENDED_EXPONENT_OFFSET;
long extendedMantissa = doubleMantissa
<< (EXTENDED_MANTISSA_LENGTH - DOUBLE_MANTISSA_LENGTH);
long extendedSign = sign << EXTENDED_EXPONENT_LENGTH;
short extendedBits79To64 = (short) (extendedSign | extendedExponent);
long extendedBits63To0 = EXTENDED_INTEGER_MASK | extendedMantissa;
dos.writeShort(extendedBits79To64);
dos.writeLong(extendedBits63To0);
}
示例11: write
import java.io.DataOutputStream; //导入方法依赖的package包/类
public void write(DataOutputStream paramDataOutputStream, ConstantPool paramConstantPool) throws IOException {
this.accessFlags.write(paramDataOutputStream);
this.iNameIndex = paramConstantPool.getIndexOf(this.cpName);
paramDataOutputStream.writeShort(this.iNameIndex);
this.iDescriptorIndex = paramConstantPool.getIndexOf(this.cpDescriptor);
paramDataOutputStream.writeShort(this.iDescriptorIndex);
this.attributes.write(paramDataOutputStream, paramConstantPool);
}
示例12: write
import java.io.DataOutputStream; //导入方法依赖的package包/类
public void write(DataOutputStream out) throws IOException {
/*
* Write all the items of the "field_info" structure.
* See JVMS section 4.5.
*/
// u2 access_flags;
out.writeShort(accessFlags);
// u2 name_index;
out.writeShort(cp.getUtf8(name));
// u2 descriptor_index;
out.writeShort(cp.getUtf8(descriptor));
// u2 attributes_count;
out.writeShort(0); // (no field_info attributes for proxy classes)
}
示例13: writeShortTable
import java.io.DataOutputStream; //导入方法依赖的package包/类
private static void writeShortTable(DataOutputStream out, short[] data)
throws IOException {
for (short val : data) {
out.writeShort(val);
}
}
示例14: sendBlockSync
import java.io.DataOutputStream; //导入方法依赖的package包/类
public void sendBlockSync(int client, int x, int y, int viewx, int viewy){
BlockSyncPacket packet = new BlockSyncPacket();
ByteArrayOutputStream bs = new ByteArrayOutputStream();
//TODO compress stream
try {
DataOutputStream stream = new DataOutputStream(bs);
stream.writeFloat(Timers.time());
for (int rx = -viewx / 2; rx <= viewx / 2; rx++) {
for (int ry = -viewy / 2; ry <= viewy / 2; ry++) {
Tile tile = Vars.world.tile(x + rx, y + ry);
if (tile == null || tile.entity == null) continue;
stream.writeInt(tile.packedPosition());
byte times = 0;
for(; times < tile.entity.timer.getTimes().length; times ++){
if(tile.entity.timer.getTimes()[times] <= 1f){
break;
}
}
stream.writeByte(times);
for(int i = 0; i < times; i ++){
stream.writeFloat(tile.entity.timer.getTimes()[i]);
}
stream.writeShort(tile.getPackedData());
tile.entity.write(stream);
}
}
}catch (IOException e){
throw new RuntimeException(e);
}
packet.stream = new ByteArrayInputStream(bs.toByteArray());
Net.sendStream(client, packet);
}
示例15: writeQuestion
import java.io.DataOutputStream; //导入方法依赖的package包/类
private static void writeQuestion(OutputStream out, String domain) throws IOException {
DataOutputStream dos = new DataOutputStream(out);
writeDomain(out, domain);
dos.writeShort(1);
dos.writeShort(1);
}