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

The following examples show how to use java.io.DataOutputStream#writeDouble() . These examples are extracted from open source projects. 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
/**
 * 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
/**
 * 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 3
Source Project: netbeans   File: CPUCCTContainer.java    License: 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 4
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 5
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 6
/**
 * 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 7
Source Project: incubator-pinot   File: NumberUtils.java    License: 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 8
Source Project: awacs   File: PrimitiveConstant.java    License: 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 9
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 10
Source Project: micro-integrator   File: MDDProducer.java    License: 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 11
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 12
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 13
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 14
Source Project: ForgeHax   File: BreadCrumbs.java    License: 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 15
Source Project: GNSS_Compare   File: IonoGps.java    License: 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 16
/**
 * 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
/**
 * 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
/**
 * 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 Project: birt   File: IOUtil.java    License: 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 Project: commons-bcel   File: ConstantDouble.java    License: 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);
}