Determining if a File or Directory Exists


boolean exists = (new File("filename")).exists(); if (exists) {    // File or directory exists } else {    // File or directory does not exist }



In this phrase, we use the exists() method on the File object to determine if the file or directory represented by the File object exists. The exists() method will return true if the file or directory exists, otherwise it will return false.




JavaT Phrasebook. Essential Code and Commands
Java Phrasebook
ISBN: 0672329077
EAN: 2147483647
Year: 2004
Pages: 166

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net