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


Java DataOutputStream.writeShort方法代码示例

本文整理汇总了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));
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:18,代码来源:LittleEndianDataInputStreamTest.java

示例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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:28,代码来源:ProxyGenerator.java

示例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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:BinaryAttribute.java

示例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);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:ProxyGenerator.java

示例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);
    }
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:9,代码来源:Methods.java

示例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
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:EnumElementValueGen.java

示例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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:BootstrapMethod.java

示例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;"));
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:17,代码来源:ProxyGenerator.java

示例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;"));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:ProxyGenerator.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:AiffFileWriter.java

示例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);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:9,代码来源:FieldInfo.java

示例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)
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:15,代码来源:ProxyGenerator.java

示例13: writeShortTable

import java.io.DataOutputStream; //导入方法依赖的package包/类
private static void writeShortTable(DataOutputStream out, short[] data)
    throws IOException {
    for (short val : data) {
        out.writeShort(val);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:FontConfiguration.java

示例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);
}
 
开发者ID:Anuken,项目名称:Mindustry,代码行数:47,代码来源:NetServer.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:7,代码来源:DnsMessage.java


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