mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-01-23 05:21:49 +01:00
commit
0148436e1b
@ -1,33 +0,0 @@
|
|||||||
package edu.tsinghua.spice.Utilies;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.RandomAccessFile;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Denny C. Ng on 2/20/15.
|
|
||||||
*/
|
|
||||||
public class SpiceIOUtil {
|
|
||||||
|
|
||||||
public static byte[] readFile(String file) throws IOException {
|
|
||||||
return readFile(new File(file));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] readFile(File file) throws IOException {
|
|
||||||
// Open file
|
|
||||||
RandomAccessFile f = new RandomAccessFile(file, "r");
|
|
||||||
try {
|
|
||||||
// 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;
|
|
||||||
} finally {
|
|
||||||
f.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user