Package java.io

Examples of java.io.DataInputStream.readFloat()


   */
  public static float[] readFloat(String file) throws IOException{
    ArrayList<Float> data = new ArrayList<Float>(1000);
    DataInputStream in = new DataInputStream(new FileInputStream(file));
    while(in.available()>0){
      data.add(in.readFloat());
    }
    in.close();
    float[] floatData = new float[data.size()];
    for(int i=0; i<floatData.length; ++i){
      floatData[i] = data.get(i);
View Full Code Here


 
  private static float[][] readFloatByRow(String file, int first, int skipBytes,int rowNumber, int columnNumber) throws IOException{
    DataInputStream in = new DataInputStream(new FileInputStream(file));
    float[][] data = new float[rowNumber][columnNumber];
    in.skipBytes(first);
    data[0][0] = in.readFloat();
    for(int colIndex=1; colIndex<columnNumber; ++colIndex){
      in.skipBytes(skipBytes);
      data[0][colIndex] = in.readFloat();
    }
    for(int rowIndex=1; rowIndex<rowNumber; ++rowIndex){
View Full Code Here

    float[][] data = new float[rowNumber][columnNumber];
    in.skipBytes(first);
    data[0][0] = in.readFloat();
    for(int colIndex=1; colIndex<columnNumber; ++colIndex){
      in.skipBytes(skipBytes);
      data[0][colIndex] = in.readFloat();
    }
    for(int rowIndex=1; rowIndex<rowNumber; ++rowIndex){
      for(int colIndex=0; colIndex<columnNumber; ++colIndex){
        in.skipBytes(skipBytes);
        data[rowIndex][colIndex] = in.readFloat();
View Full Code Here

      data[0][colIndex] = in.readFloat();
    }
    for(int rowIndex=1; rowIndex<rowNumber; ++rowIndex){
      for(int colIndex=0; colIndex<columnNumber; ++colIndex){
        in.skipBytes(skipBytes);
        data[rowIndex][colIndex] = in.readFloat();
      }
    }
    in.close();
    return data;
  }
View Full Code Here

 
  private static float[][] readFloatByColumn(String file, int first, int skipBytes,int rowNumber, int columnNumber) throws IOException{
    DataInputStream in = new DataInputStream(new FileInputStream(file));
    float[][] data = new float[rowNumber][columnNumber];
    in.skipBytes(first);
    data[0][0] = in.readFloat();
    for(int rowIndex=1; rowIndex<rowNumber; ++rowIndex){
      in.skipBytes(skipBytes);
      data[rowIndex][0] = in.readFloat();
    }
    for(int colIndex=1; colIndex<columnNumber; ++colIndex){
View Full Code Here

    float[][] data = new float[rowNumber][columnNumber];
    in.skipBytes(first);
    data[0][0] = in.readFloat();
    for(int rowIndex=1; rowIndex<rowNumber; ++rowIndex){
      in.skipBytes(skipBytes);
      data[rowIndex][0] = in.readFloat();
    }
    for(int colIndex=1; colIndex<columnNumber; ++colIndex){
      for(int rowIndex=0; rowIndex<rowNumber; ++rowIndex){
        in.skipBytes(skipBytes);
        data[rowIndex][colIndex] = in.readFloat();
View Full Code Here

      data[rowIndex][0] = in.readFloat();
    }
    for(int colIndex=1; colIndex<columnNumber; ++colIndex){
      for(int rowIndex=0; rowIndex<rowNumber; ++rowIndex){
        in.skipBytes(skipBytes);
        data[rowIndex][colIndex] = in.readFloat();
      }
    }
    in.close();
    return data;
  }
View Full Code Here

          if ("d".equals(dataType)) {
            double dv = input.readDouble();
            LOG.info("metrics " + name + " value:" + dv);
            record.add(new Metric<Double>(name, dv));
          } else if ("f".equals(dataType)) {
            float fv = input.readFloat();
            LOG.info("metrics " + name + " value:" + fv);
            record.add(new Metric<Float>(name, fv));
          } else if ("i".equals(dataType)) {
            int iv = input.readInt();
            LOG.info("metrics " + name + " value:" + iv);
View Full Code Here

        // make sure the contents are really the same
        ByteArrayInputStream bytesIn = new ByteArrayInputStream(inboundPacket.getData());
        DataInputStream dataIn = new DataInputStream(bytesIn);
        // the delta is only here to make JUnit happy
        assertEquals(1.0f, dataIn.readFloat(), 0.1f);
        assertEquals(2.0f, dataIn.readFloat(), 0.1f);
    }
}
View Full Code Here

        // make sure the contents are really the same
        ByteArrayInputStream bytesIn = new ByteArrayInputStream(inboundPacket.getData());
        DataInputStream dataIn = new DataInputStream(bytesIn);
        // the delta is only here to make JUnit happy
        assertEquals(1.0f, dataIn.readFloat(), 0.1f);
        assertEquals(2.0f, dataIn.readFloat(), 0.1f);
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.