Android File Exist isFileExist(String pathAndFileName)

Here you can find the source of isFileExist(String pathAndFileName)

Description

Tests whether the file denoted by this abstract pathname is a normal file.

License

Open Source License

Parameter

Parameter Description
pathAndFileName - name of file and FULL path for it

Return

- true if file exists and - false if file absense default directory(path) for downloaded files - true if and only if the file denoted by this abstract pathname exists and is a normal file; - false otherwise

Declaration

public static boolean isFileExist(String pathAndFileName) 

Method Source Code

/****************************************************************************
 * Copyright (C) 2014 GGA Software Services LLC
 *
 * This file may be distributed and/or modified under the terms of the
 * GNU General Public License version 3 as published by the Free Software
 * Foundation.//from   w  ww.j a v  a  2  s .  c o  m
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses>.
 ***************************************************************************/

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.CookieStore;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.cookie.BasicClientCookie;
import org.openqa.selenium.Cookie;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Set;

public class Main{
    /**
     * Tests whether the file denoted by this abstract pathname is a normal
     * file.  A file is <em>normal</em> if it is not a directory and, in
     * addition, satisfies other system-dependent criteria.  Any non-directory
     * file created by a Java application is guaranteed to be a normal file.
     *
     * @param pathAndFileName - name of file and FULL path for it
     *
     * @return
     * - true if file exists and
     * - false if file absense default directory(path) for downloaded files
     * - true if and only if the file denoted by this abstract pathname exists and is a normal file;
     * - false otherwise
     */
    public static boolean isFileExist(String pathAndFileName) {
        ReporterNGExt.logTechnical(String.format("isFileExist: %s",
                pathAndFileName));
        File findFile = new File(pathAndFileName);
        return findFile.isFile();
    }
}

Related

  1. isFileExist(String fileName)
  2. isFileExist(String folder, String fileName)
  3. isFileExist(String path)
  4. isFileExist(String path)
  5. isFileExist(String path, String fileName)
  6. judgeFileExist(String p_sFilePath)
  7. isExistFile(String name)
  8. isFileExists(String filename)
  9. isExist(String absPath)