| | |
| | | import java.io.BufferedOutputStream;
|
| | | import java.io.File;
|
| | | import java.io.FileOutputStream;
|
| | | import java.io.IOException;
|
| | | import java.io.RandomAccessFile;
|
| | |
|
| | | import cn.com.basic.face.base.MainActivity;
|
| | |
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | |
|
| | | public static byte[] readFile(File file) {
|
| | | // Open file
|
| | | RandomAccessFile f = null;
|
| | | try {
|
| | | f = new RandomAccessFile(file, "r");
|
| | | // Get and check length
|
| | | long longlength = f.length();
|
| | | int length = (int) longlength;
|
| | | if (length != longlength)
|
| | | throw new IOException("File size >= 2 GB");
|
| | | // Read file and return data
|
| | | byte[] data = new byte[length];
|
| | | f.readFully(data);
|
| | | return data;
|
| | | } catch (Exception e){
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | try {
|
| | | f.close();
|
| | | }catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | return new byte[]{};
|
| | | }
|
| | |
|
| | |
|
| | | }
|