Code example for File

Methods: exists, getAbsolutePath, length

0
                    e);
        } 
    } 
 
    public static byte[] readDataFromStorage(File file) {
        if (!file.exists()) {
            Log.d(LOG_TAG, "readDataFromStorage(): File does not exist: "
                    + file.getAbsolutePath());
            return null; 
        } 
 
        byte[] bytes = null;
        try { 
            FileInputStream fis = null;
            try { 
                fis = new FileInputStream(file);
                bytes = new byte[(int)file.length()];
                fis.read(bytes);
            } finally { 
                if (fis != null) {
                    fis.close();
                } 
            } 
        } catch (IOException e) {
            Log.e(LOG_TAG, "file.getAbsolutePath=" + file.getAbsolutePath(), e);
        } 
 
        return bytes;
    }