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()];
fin.read(byteArray);
fin.close();
Friday, June 24, 2011
Java: read data as byte array from file
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment