Skip to content

Instantly share code, notes, and snippets.

@lgordon
Created March 6, 2013 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgordon/5103515 to your computer and use it in GitHub Desktop.
Save lgordon/5103515 to your computer and use it in GitHub Desktop.
public static float[] getFloatC(String filename)
throws FileNotFoundException, IOException{
File fl = new File(filename);
FileInputStream str = new FileInputStream(fl);
FileChannel ch = str.getChannel();
MappedByteBuffer mb = ch.map( FileChannel.MapMode.READ_ONLY, 0L, ch.size( ));
int numfloats = (int) ch.size()/4;
float[] result = new float [numfloats];
try{
for(int j=0;j<numfloats;j++){
result [j] = mb.getFloat();
}
} finally{
str.close();
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment