Friday, June 24, 2011

Java: read data as byte array from file

Using the FileInputStream of java, you can read data from a file into a byte array. Below is the sample code that will fill the byte array from the provided file.

String fileName = "test.txt";
File file = new File(fileName);
FileInputStream fin = new FileInputStream(file);
byte byteArray[] = new byte[(int)file.length()];;

No comments:

Get function name programaticaly - Python

This little piece of code will help you to get the function name programatically. This is very helpful when you are implementing the debug...