當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。