Refine search
DataInputStream in = new DataInputStream(new BufferedInputStream( new FileInputStream("filename"))); int x = in.readInt(); double y = in.readDouble(); etc.
public static VerticalDatum fromGTX (InputStream inputStream) throws IOException { DataInputStream stream = new DataInputStream(new BufferedInputStream(inputStream)); double lowerLeftLatitude = stream.readDouble(); double lowerLeftLongitude = stream.readDouble(); if (lowerLeftLongitude > 180) { lowerLeftLongitude -= 360; //convert to standard coordinates } double deltaLatitude = stream.readDouble(); double deltaLongitude = stream.readDouble(); int nRows = stream.readInt(); int nColumns = stream.readInt(); float[][] data = new float[nRows][nColumns]; for (int y = 0; y < nRows; ++y) { for (int x = 0; x < nColumns; ++x) { data[y][x] = stream.readFloat(); } } return new VerticalDatum(lowerLeftLongitude, lowerLeftLatitude, deltaLatitude * nColumns, deltaLongitude * nRows, data); }
public static QDigest deserialize(byte[] b) { ByteArrayInputStream bis = new ByteArrayInputStream(b); DataInputStream s = new DataInputStream(bis); try { long size = s.readLong(); double compressionFactor = s.readDouble(); long capacity = s.readLong(); int count = s.readInt(); QDigest d = new QDigest(compressionFactor); d.size = size; d.capacity = capacity; for (int i = 0; i < count; ++i) { long k = s.readLong(); long n = s.readLong(); d.node2count.put(k, n); } return d; } catch (IOException e) { throw new RuntimeException(e); } }
/** * Performs authorization on given DatagramPacket. * * @param packet to authorize * @return offset in DatagramPacket where request payload starts * @throws Exception thrown if passcode received from client does not match set passcode */ protected int authorizeProbeRequest(DatagramPacket packet) throws Exception { int offset = 0; ByteArrayInputStream bis = new ByteArrayInputStream(packet.getData()); DataInputStream in = new DataInputStream(bis); long t1 = in.readLong(); double q1 = in.readDouble(); int length = in.readInt(); byte[] digest = new byte[length]; in.readFully(digest); offset = 8 + 8 + 4 + digest.length; byte[] local = Util.createDigest(passcode, t1, q1); if(!MessageDigest.isEqual(digest, local)) throw new Exception("Authorization failed! Make sure correct passcode is used"); else log.debug("Request authorized"); return offset; }
break; case 'I': data[i] = in.readInt(); break; case 'F': break; case 'D': data[i] = Double.valueOf(in.readDouble()); break; case 'i':
break; case INTEGER_TYPE: value = Integer.valueOf(in.readInt()); break; case LONG_TYPE: break; case DOUBLE_TYPE: value = new Double(in.readDouble()); break; case BYTE_ARRAY_TYPE: value = new byte[in.readInt()]; in.readFully((byte[])value); break; value = readUTF8(in); } else { value = readUTF(in, in.readInt());
Class<?> type = element.field.getType(); if (type == int.class) { element.fieldValue = input.readInt(); } else if (type == byte.class) { element.fieldValue = input.readByte(); element.fieldValue = input.readFloat(); } else if (type == double.class) { element.fieldValue = input.readDouble(); } else {
pool.add(new PrimitiveConstant(CodeConstants.CONSTANT_Integer, Integer.valueOf(in.readInt()))); break; pool.add(new PrimitiveConstant(CodeConstants.CONSTANT_Double, in.readDouble())); pool.add(null); i++;
/** * Restore a MultiNormalizerMinMaxScaler that was previously serialized by this strategy * * @param stream the input stream to restore from * @return the restored MultiNormalizerMinMaxScaler * @throws IOException */ public MultiNormalizerMinMaxScaler restore(@NonNull InputStream stream) throws IOException { DataInputStream dis = new DataInputStream(stream); boolean fitLabels = dis.readBoolean(); int numInputs = dis.readInt(); int numOutputs = dis.readInt(); double targetMin = dis.readDouble(); double targetMax = dis.readDouble(); MultiNormalizerMinMaxScaler result = new MultiNormalizerMinMaxScaler(targetMin, targetMax); result.fitLabel(fitLabels); List<MinMaxStats> featureStats = new ArrayList<>(); for (int i = 0; i < numInputs; i++) { featureStats.add(new MinMaxStats(Nd4j.read(dis), Nd4j.read(dis))); } result.setFeatureStats(featureStats); if (fitLabels) { List<MinMaxStats> labelStats = new ArrayList<>(); for (int i = 0; i < numOutputs; i++) { labelStats.add(new MinMaxStats(Nd4j.read(dis), Nd4j.read(dis))); } result.setLabelStats(labelStats); } return result; }
return new Integer(this.dataIn.readInt()).toString(); return new Double(this.dataIn.readDouble()).toString();
int size = input.readInt(); Class<?> arrayClass = classDesc.forClass(); Class<?> componentType = arrayClass.getComponentType(); int[] intArray = (int[]) result; for (int i = 0; i < size; i++) { intArray[i] = input.readInt(); double[] doubleArray = (double[]) result; for (int i = 0; i < size; i++) { doubleArray[i] = input.readDouble();
int theType = dis.readInt(); newValue( theType ); int nameLength = dis.readInt(); setLength( dis.readInt(), dis.readInt() ); setValue( dis.readDouble() ); break; case VALUE_TYPE_INTEGER:
return new JsonValue(oldFormat ? (long)din.readShort() : (long)din.readByte()); else if (type == 'I') return new JsonValue(oldFormat ? (long)din.readInt() : (long)din.readShort()); else if (type == 'l') return new JsonValue((long)din.readInt()); else if (type == 'L') return new JsonValue(din.readLong()); return new JsonValue(din.readFloat()); else if (type == 'D') return new JsonValue(din.readDouble()); else if (type == 's' || type == 'S') return new JsonValue(parseString(din, type));
return new JsonValue(oldFormat ? (long)din.readShort() : (long)din.readByte()); else if (type == 'I') return new JsonValue(oldFormat ? (long)din.readInt() : (long)din.readShort()); else if (type == 'l') return new JsonValue((long)din.readInt()); else if (type == 'L') return new JsonValue(din.readLong()); return new JsonValue(din.readFloat()); else if (type == 'D') return new JsonValue(din.readDouble()); else if (type == 's' || type == 'S') return new JsonValue(parseString(din, type));
if (currentType == Type.DOUBLE) { for (int i = 0; i < length(); i++) { putByGlobalType(i, s.readDouble(), globalType); putByGlobalType(i, s.readInt(), globalType);
return Integer.valueOf(this.dataIn.readInt()); return new Double(this.dataIn.readDouble()); int len = this.dataIn.readInt(); byte[] value = new byte[len]; this.dataIn.readFully(value);
double d = input.readDouble(); if (field != null) { field.setDouble(obj, d); int i = input.readInt(); if (field != null) { field.setInt(obj, i);
return new ShortTag(is.readShort()); case NBTConstants.TYPE_INT: return new IntTag(is.readInt()); case NBTConstants.TYPE_LONG: return new LongTag(is.readLong()); return new FloatTag(is.readFloat()); case NBTConstants.TYPE_DOUBLE: return new DoubleTag(is.readDouble()); case NBTConstants.TYPE_BYTE_ARRAY: int length = is.readInt(); byte[] bytes = new byte[length]; is.readFully(bytes); case NBTConstants.TYPE_LIST: int childType = is.readByte(); length = is.readInt();
case VALUE_TYPE_STRING: int stringLength = dis.readInt(); if ( stringLength < 0 ) { setValue( (String) null ); case VALUE_TYPE_BIGNUMBER: int bnLength = dis.readInt(); if ( bnLength < 0 ) { setValue( (BigDecimal) null ); setValue( dis.readDouble() ); break; case VALUE_TYPE_INTEGER:
return new IntTag(is.readInt()); return new DoubleTag(is.readDouble()); int length = is.readInt(); readLimiter.read(length); byte[] bytes = new byte[length]; readLimiter.read(37); TagType childType = TagType.byIdOrError(is.readUnsignedByte()); length = is.readInt(); readLimiter.read(4 * length);