Code example for RandomAccessFile

Methods: close, readByte

0
     * @return true if file exists and is non-empty. 
     */ 
    private boolean nonEmptyFileExists(String filename) { 
        try { 
            // Check if we can read a byte from the file 
            RandomAccessFile raf = new RandomAccessFile(filename, "r"); 
            raf.readByte(); 
            raf.close(); 
            return true; 
        } catch (FileNotFoundException fnfe) { 
            return false; 
        } catch (IOException ioe) { 
            return false; 
        } 
    } 
 
    /** 
     * Check to see if the user has stored a lock pattern. 
     * @return Whether a saved pattern exists. 
     */ 
    public boolean savedPatternExists() {