Code example for RandomAccessFile

Methods: closelengthreadFully

public final class IOHelpers { 
	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];
			return data;
		finally { 
	// Convert the image URI to the direct file system path of the image file 
	public static String getRealPathFromURI(Uri contentUri, Activity activity) {