Java Code Examples for java.io.DataOutputStream#writeDouble()

The following examples show how to use java.io.DataOutputStream#writeDouble() . 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: NumberConstantData.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Write the constant to the output stream
 */
void write(Environment env, DataOutputStream out, ConstantPool tab) throws IOException {
    if (num instanceof Integer) {
        out.writeByte(CONSTANT_INTEGER);
        out.writeInt(num.intValue());
    } else if (num instanceof Long) {
        out.writeByte(CONSTANT_LONG);
        out.writeLong(num.longValue());
    } else if (num instanceof Float) {
        out.writeByte(CONSTANT_FLOAT);
        out.writeFloat(num.floatValue());
    } else if (num instanceof Double) {
        out.writeByte(CONSTANT_DOUBLE);
        out.writeDouble(num.doubleValue());
    }
}
 
Example 2
Source File: ProxyGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void write(DataOutputStream out) throws IOException {
    if (value instanceof String) {
        out.writeByte(CONSTANT_UTF8);
        out.writeUTF((String) value);
    } else if (value instanceof Integer) {
        out.writeByte(CONSTANT_INTEGER);
        out.writeInt(((Integer) value).intValue());
    } else if (value instanceof Float) {
        out.writeByte(CONSTANT_FLOAT);
        out.writeFloat(((Float) value).floatValue());
    } else if (value instanceof Long) {
        out.writeByte(CONSTANT_LONG);
        out.writeLong(((Long) value).longValue());
    } else if (value instanceof Double) {
        out.writeDouble(CONSTANT_DOUBLE);
        out.writeDouble(((Double) value).doubleValue());
    } else {
        throw new InternalError("bogus value entry: " + value);
    }
}
 
Example 3
Source File: PrimitiveConstant.java    From awacs with Apache License 2.0 6 votes vote down vote up
public void writeToStream(DataOutputStream out) throws IOException {

    out.writeByte(type);
    switch (type) {
      case CONSTANT_Integer:
        out.writeInt(getInt());
        break;
      case CONSTANT_Float:
        out.writeFloat(getFloat());
        break;
      case CONSTANT_Long:
        out.writeLong(getLong());
        break;
      case CONSTANT_Double:
        out.writeDouble(getDouble());
        break;
      case CONSTANT_Utf8:
        out.writeUTF(getString());
        break;
      default: // CONSTANT_Class, CONSTANT_String, CONSTANT_MethodType
        out.writeShort(index);
    }
  }
 
Example 4
Source File: NumberUtils.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
public static void addToDataOutputStream(DataOutputStream dataOutputStream, Number value,
    MetricType type) throws IOException {
  switch (type) {
  case SHORT:
    dataOutputStream.writeShort(value.shortValue());
    break;
  case INT:
    dataOutputStream.writeInt(value.intValue());
    break;
  case LONG:
    dataOutputStream.writeLong(value.longValue());
    break;
  case FLOAT:
    dataOutputStream.writeFloat(value.floatValue());
    break;
  case DOUBLE:
    dataOutputStream.writeDouble(value.doubleValue());
    break;
  }
}
 
Example 5
Source File: NumberConstantData.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Write the constant to the output stream
 */
void write(Environment env, DataOutputStream out, ConstantPool tab) throws IOException {
    if (num instanceof Integer) {
        out.writeByte(CONSTANT_INTEGER);
        out.writeInt(num.intValue());
    } else if (num instanceof Long) {
        out.writeByte(CONSTANT_LONG);
        out.writeLong(num.longValue());
    } else if (num instanceof Float) {
        out.writeByte(CONSTANT_FLOAT);
        out.writeFloat(num.floatValue());
    } else if (num instanceof Double) {
        out.writeByte(CONSTANT_DOUBLE);
        out.writeDouble(num.doubleValue());
    }
}
 
Example 6
Source File: CPUCCTContainer.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public void writeToStream(DataOutputStream out) throws IOException {
    out.writeInt(threadId);
    out.writeUTF(threadName);

    out.writeBoolean(collectingTwoTimeStamps);

    out.writeInt(compactData.length);
    out.write(compactData);
    out.writeInt(nodeSize);

    out.writeLong(wholeGraphGrossTimeAbs);
    out.writeLong(wholeGraphGrossTimeThreadCPU);
    out.writeDouble(timeInInjectedCodeInAbsCounts);
    out.writeDouble(timeInInjectedCodeInThreadCPUCounts);
    out.writeLong(wholeGraphPureTimeAbs);
    out.writeLong(wholeGraphPureTimeThreadCPU);
    out.writeLong(wholeGraphNetTime0);
    out.writeLong(wholeGraphNetTime1);
    out.writeLong(totalInvNo);
    out.writeBoolean(displayWholeThreadCPUTime);
}
 
Example 7
Source File: ProxyGenerator.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void write(DataOutputStream out) throws IOException {
    if (value instanceof String) {
        out.writeByte(CONSTANT_UTF8);
        out.writeUTF((String) value);
    } else if (value instanceof Integer) {
        out.writeByte(CONSTANT_INTEGER);
        out.writeInt(((Integer) value).intValue());
    } else if (value instanceof Float) {
        out.writeByte(CONSTANT_FLOAT);
        out.writeFloat(((Float) value).floatValue());
    } else if (value instanceof Long) {
        out.writeByte(CONSTANT_LONG);
        out.writeLong(((Long) value).longValue());
    } else if (value instanceof Double) {
        out.writeDouble(CONSTANT_DOUBLE);
        out.writeDouble(((Double) value).doubleValue());
    } else {
        throw new InternalError("bogus value entry: " + value);
    }
}
 
Example 8
Source File: CPUCCTContainer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void writeToStream(DataOutputStream out) throws IOException {
    out.writeInt(threadId);
    out.writeUTF(threadName);

    out.writeBoolean(collectingTwoTimeStamps);

    out.writeInt(compactData.length);
    out.write(compactData);
    out.writeInt(nodeSize);

    out.writeLong(wholeGraphGrossTimeAbs);
    out.writeLong(wholeGraphGrossTimeThreadCPU);
    out.writeDouble(timeInInjectedCodeInAbsCounts);
    out.writeDouble(timeInInjectedCodeInThreadCPUCounts);
    out.writeLong(wholeGraphPureTimeAbs);
    out.writeLong(wholeGraphPureTimeThreadCPU);
    out.writeLong(wholeGraphNetTime0);
    out.writeLong(wholeGraphNetTime1);
    out.writeLong(totalInvNo);
    out.writeBoolean(displayWholeThreadCPUTime);
}
 
Example 9
Source File: NTRUSigningParameters.java    From RipplePower with Apache License 2.0 6 votes vote down vote up
/**
 * Writes the parameter set to an output stream
 *
 * @param os an output stream
 * @throws IOException
 */
public void writeTo(OutputStream os)
    throws IOException
{
    DataOutputStream dos = new DataOutputStream(os);
    dos.writeInt(N);
    dos.writeInt(q);
    dos.writeInt(d);
    dos.writeInt(d1);
    dos.writeInt(d2);
    dos.writeInt(d3);
    dos.writeInt(B);
    dos.writeDouble(beta);
    dos.writeDouble(normBound);
    dos.writeInt(signFailTolerance);
    dos.writeInt(bitsF);
    dos.writeUTF(hashAlg.getAlgorithmName());
}
 
Example 10
Source File: CCQuantifierDataManager.java    From jatecs with GNU General Public License v3.0 5 votes vote down vote up
public void write(IStorageManager storageManager, String modelName,
                  IQuantifier quantifier) {
    try {
        CCQuantifier ccQuantifier = (CCQuantifier) quantifier;
        classifierDataManager.write(storageManager, modelName
                + classifierSuffix, ccQuantifier.getClassifier());
        classifierDataManager.writeClassifierRuntimeConfiguration(
                storageManager, modelName + classifierSuffix, ccQuantifier
                        .getClassifier().getRuntimeCustomizer());
        DataOutputStream output = new DataOutputStream(
                storageManager.getOutputStreamForResource(modelName
                        + thresholdSuffix));
        if (ccQuantifier.getClassificationMode() == ClassificationMode.PER_DOCUMENT) {
            output.writeBoolean(true);
        } else {
            output.writeBoolean(false);
        }
        if (ccQuantifier.hasCustomThresholds()) {
            output.writeBoolean(true);
            TShortDoubleHashMap thresholds = ccQuantifier
                    .getCustomThresholds();
            output.writeInt(thresholds.size());
            TShortDoubleIterator iterator = thresholds.iterator();
            while (iterator.hasNext()) {
                iterator.advance();
                output.writeShort(iterator.key());
                output.writeDouble(iterator.value());
            }
        } else {
            output.writeBoolean(false);
        }
        output.close();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example 11
Source File: DistributionalRandomOversampling.java    From jatecs with GNU General Public License v3.0 5 votes vote down vote up
private void saveProbModel(int docid,
		CumumlativeProbFunction docFeatProbDist, DataOutputStream fo) throws IOException {
	
	DenseVector massfunc = docFeatProbDist.getProbabilityMass();
	fo.writeInt(docid);
	for(int i = 0; i < massfunc.size(); i++){
		fo.writeDouble(massfunc.get(i));
	}		
}
 
Example 12
Source File: BreadCrumbs.java    From ForgeHax with MIT License 5 votes vote down vote up
private static void writeTrail(Trail trail, DataOutputStream dos) throws IOException {
  dos.writeInt(trail.dimension);
  dos.writeInt(trail.points.size());
  for (Vec3d p : trail.points) {
    dos.writeDouble(p.x);
    dos.writeDouble(p.y);
    dos.writeDouble(p.z);
  }
}
 
Example 13
Source File: N3streamWriter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private int writeAttributeValue(DataOutputStream stream, Number numValue) throws IOException {
  if (numValue instanceof Byte) {
    if (null != stream)
      stream.write(numValue.byteValue());
    return 1;

  } else if (numValue instanceof Short) {
    if (null != stream)
      stream.writeShort(numValue.shortValue());
    return 2;

  } else if (numValue instanceof Integer) {
    if (null != stream)
      stream.writeInt(numValue.intValue());
    return 4;

  } else if (numValue instanceof Float) {
    if (null != stream)
      stream.writeFloat(numValue.floatValue());
    return 4;

  } else if (numValue instanceof Double) {
    if (null != stream)
      stream.writeDouble(numValue.doubleValue());
    return 8;
  }

  throw new IllegalStateException("unknown attribute type == " + numValue.getClass().getName());
}
 
Example 14
Source File: IonoGps.java    From GNSS_Compare with Apache License 2.0 5 votes vote down vote up
@Override
public int write(DataOutputStream dos) throws IOException {
	int size=5;
	dos.writeUTF(MESSAGE_IONO); // 5
	dos.writeInt(STREAM_V); size +=4;
	dos.writeLong(health); size +=8;
	dos.writeDouble(utcA1); size +=8;
	dos.writeDouble(utcA0); size +=8;
	dos.writeLong(utcTOW); size +=8;
	dos.writeInt(utcWNT); size +=4;
	dos.writeInt(utcLS); size +=4;
	dos.writeInt(utcWNF); size +=4;
	dos.writeInt(utcDN); size +=4;
	dos.writeInt(utcLSF); size +=4;
	for(int i=0;i<alpha.length;i++){
		dos.writeFloat(alpha[i]); size +=4;
	}
	for(int i=0;i<beta.length;i++){
		dos.writeFloat(beta[i]); size +=4;
	}
	dos.writeBoolean(validHealth);  size +=1;
	dos.writeBoolean(validUTC); size +=1;
	dos.writeBoolean(validKlobuchar); size +=1;
	dos.writeLong(refTime==null?-1:refTime.getMsec());  size +=8;

	return size;
}
 
Example 15
Source File: MDDProducer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public void sendMessage(String symbol, String destination) throws Exception {

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(bos);
        dos.writeDouble(getRandom(1, 1, true));
        dos.writeUTF(symbol);
        dos.writeDouble(Double.valueOf("100.20"));
        dos.writeUTF("NYSE");
        dos.flush();
        sendBytesMessage(destination, bos.toByteArray());
        dos.close();
        bos.close();
    }
 
Example 16
Source File: BinaryConstantPool.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write out the contents of the constant pool, including any additions
 * that have been added.
 */
public void write(DataOutputStream out, Environment env) throws IOException {
    int length = cpool.length;
    if (MoreStuff != null)
        length += MoreStuff.size();
    out.writeShort(length);
    for (int i = 1 ; i < cpool.length; i++) {
        int type = types[i];
        Object x = cpool[i];
        out.writeByte(type);
        switch (type) {
            case CONSTANT_UTF8:
                out.writeUTF((String) x);
                break;
            case CONSTANT_INTEGER:
                out.writeInt(((Number)x).intValue());
                break;
            case CONSTANT_FLOAT:
                out.writeFloat(((Number)x).floatValue());
                break;
            case CONSTANT_LONG:
                out.writeLong(((Number)x).longValue());
                i++;
                break;
            case CONSTANT_DOUBLE:
                out.writeDouble(((Number)x).doubleValue());
                i++;
                break;
            case CONSTANT_CLASS:
            case CONSTANT_STRING:
                out.writeShort(((Number)x).intValue());
                break;
            case CONSTANT_FIELD:
            case CONSTANT_METHOD:
            case CONSTANT_INTERFACEMETHOD:
            case CONSTANT_NAMEANDTYPE: {
                int value = ((Number)x).intValue();
                out.writeShort(value >> 16);
                out.writeShort(value & 0xFFFF);
                break;
            }
            case CONSTANT_METHODHANDLE:
            case CONSTANT_METHODTYPE:
            case CONSTANT_INVOKEDYNAMIC:
                out.write((byte[])x, 0, ((byte[])x).length);
                break;
            default:
                 throw new ClassFormatError("invalid constant type: "
                                               + (int)types[i]);
        }
    }
    for (int i = cpool.length; i < length; i++) {
        String string = (String)(MoreStuff.elementAt(i - cpool.length));
        out.writeByte(CONSTANT_UTF8);
        out.writeUTF(string);
    }
}
 
Example 17
Source File: BinaryConstantPool.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write out the contents of the constant pool, including any additions
 * that have been added.
 */
public void write(DataOutputStream out, Environment env) throws IOException {
    int length = cpool.length;
    if (MoreStuff != null)
        length += MoreStuff.size();
    out.writeShort(length);
    for (int i = 1 ; i < cpool.length; i++) {
        int type = types[i];
        Object x = cpool[i];
        out.writeByte(type);
        switch (type) {
            case CONSTANT_UTF8:
                out.writeUTF((String) x);
                break;
            case CONSTANT_INTEGER:
                out.writeInt(((Number)x).intValue());
                break;
            case CONSTANT_FLOAT:
                out.writeFloat(((Number)x).floatValue());
                break;
            case CONSTANT_LONG:
                out.writeLong(((Number)x).longValue());
                i++;
                break;
            case CONSTANT_DOUBLE:
                out.writeDouble(((Number)x).doubleValue());
                i++;
                break;
            case CONSTANT_CLASS:
            case CONSTANT_STRING:
                out.writeShort(((Number)x).intValue());
                break;
            case CONSTANT_FIELD:
            case CONSTANT_METHOD:
            case CONSTANT_INTERFACEMETHOD:
            case CONSTANT_NAMEANDTYPE: {
                int value = ((Number)x).intValue();
                out.writeShort(value >> 16);
                out.writeShort(value & 0xFFFF);
                break;
            }
            case CONSTANT_METHODHANDLE:
            case CONSTANT_METHODTYPE:
            case CONSTANT_INVOKEDYNAMIC:
                out.write((byte[])x, 0, ((byte[])x).length);
                break;
            default:
                 throw new ClassFormatError("invalid constant type: "
                                               + (int)types[i]);
        }
    }
    for (int i = cpool.length; i < length; i++) {
        String string = (String)(MoreStuff.elementAt(i - cpool.length));
        out.writeByte(CONSTANT_UTF8);
        out.writeUTF(string);
    }
}
 
Example 18
Source File: BinaryConstantPool.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write out the contents of the constant pool, including any additions
 * that have been added.
 */
public void write(DataOutputStream out, Environment env) throws IOException {
    int length = cpool.length;
    if (MoreStuff != null)
        length += MoreStuff.size();
    out.writeShort(length);
    for (int i = 1 ; i < cpool.length; i++) {
        int type = types[i];
        Object x = cpool[i];
        out.writeByte(type);
        switch (type) {
            case CONSTANT_UTF8:
                out.writeUTF((String) x);
                break;
            case CONSTANT_INTEGER:
                out.writeInt(((Number)x).intValue());
                break;
            case CONSTANT_FLOAT:
                out.writeFloat(((Number)x).floatValue());
                break;
            case CONSTANT_LONG:
                out.writeLong(((Number)x).longValue());
                i++;
                break;
            case CONSTANT_DOUBLE:
                out.writeDouble(((Number)x).doubleValue());
                i++;
                break;
            case CONSTANT_CLASS:
            case CONSTANT_STRING:
                out.writeShort(((Number)x).intValue());
                break;
            case CONSTANT_FIELD:
            case CONSTANT_METHOD:
            case CONSTANT_INTERFACEMETHOD:
            case CONSTANT_NAMEANDTYPE: {
                int value = ((Number)x).intValue();
                out.writeShort(value >> 16);
                out.writeShort(value & 0xFFFF);
                break;
            }
            case CONSTANT_METHODHANDLE:
            case CONSTANT_METHODTYPE:
            case CONSTANT_INVOKEDYNAMIC:
                out.write((byte[])x, 0, ((byte[])x).length);
                break;
            default:
                 throw new ClassFormatError("invalid constant type: "
                                               + (int)types[i]);
        }
    }
    for (int i = cpool.length; i < length; i++) {
        String string = (String)(MoreStuff.elementAt(i - cpool.length));
        out.writeByte(CONSTANT_UTF8);
        out.writeUTF(string);
    }
}
 
Example 19
Source File: IOUtil.java    From birt with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Write a double value to an output stream
 * 
 * @param outputStream
 * @param value
 * @throws IOException
 */
public final static void writeDouble( DataOutputStream outputStream,
		double value ) throws IOException
{
	outputStream.writeDouble( value );
}
 
Example 20
Source File: ConstantDouble.java    From commons-bcel with Apache License 2.0 2 votes vote down vote up
/**
 * Dump constant double to file stream in binary format.
 *
 * @param file Output file stream
 * @throws IOException
 */
@Override
public void dump( final DataOutputStream file ) throws IOException {
    file.writeByte(super.getTag());
    file.writeDouble(bytes);
}