Java File Read via ByteBuffer ReadFloat(InputStream is)

Here you can find the source of ReadFloat(InputStream is)

Description

Read Float

License

Open Source License

Declaration

public static float ReadFloat(InputStream is) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.io.InputStream;

import java.nio.ByteBuffer;

public class Main {
    private static ByteBuffer bb = ByteBuffer.allocate(8);
    private static byte[] tempBuffer = new byte[8];

    public static float ReadFloat(InputStream is) throws IOException {
        bb.position(0);//from www.  j  a v a 2 s  .co  m
        is.read(tempBuffer, 0, 4);
        bb.put(tempBuffer, 0, 4);
        return bb.getFloat(0);
    }
}

Related

  1. readFileToBuffer(java.io.File file)
  2. readFileToString(String path)
  3. readFileToString(String path)
  4. readFlashString(DataInputStream s)
  5. readFloat(BufferedReader br)
  6. readFromBuffer(byte[] buffer, int start, int end)
  7. readFromFile(Path path)
  8. readFromFile(String fileName)
  9. readFromSocket(SocketChannel channel)