Example usage for java.io File isFile

List of usage examples for java.io File isFile

Introduction

In this page you can find the example usage for java.io File isFile.

Prototype

public boolean isFile() 

Source Link

Document

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

Usage

From source file:Main.java

private static void checkFile(File file) throws IOException {
    boolean exists = file.exists();
    if (exists && !file.isFile()) {
        throw new IOException("File " + file.getPath() + " is actually not a file.");
    }//  ww w.  ja v a  2 s.c o m
}

From source file:Main.java

public static boolean deleteSpicificFile(String filePath) {
    if (!isEmpty(filePath) && isSDCardAvailable()) {
        try {//from w  w  w .ja  v a 2  s.  c om
            File file = new File(filePath);
            if (file.exists() && file.isFile()) {
                return file.delete();
            }
        } catch (Exception e) {

            if (e != null && isNotEmpty(e.getMessage())) {
                Log.e("@@@", e.getMessage());
            }
        }
    }
    return false;
}

From source file:Main.java

public static File getPiiicFile(Context paramContext, String paramString) {
    File localFile = new File(Environment.getExternalStorageDirectory(), "Piiic");
    if ((!localFile.exists()) || (localFile.isFile()))
        localFile.mkdirs();/*w w  w .  java  2s . c o  m*/
    return new File(localFile, paramString);
}

From source file:Main.java

public static String getSHA(File f, int length) {
    if (!f.isFile() || length <= 0) {
        return null;
    }/*from  ww w.ja v  a2  s. c  o  m*/
    FileInputStream f1;
    byte[] buf = new byte[length];
    int n;
    try {
        f1 = new FileInputStream(f);
        n = f1.read(buf, 0, length);
        f1.close();
    } catch (IOException e) {
        return null;
    }
    return getSHA(buf);
}

From source file:com.hangum.tadpole.engine.initialize.JDBCDriverLoader.java

/**
 * add jar loader of file/*ww  w .j a  v a 2s.  c  o  m*/
 * 
 * @param strFile
 * @throws Exception
 */
public static void addJarFile(String strFile) throws Exception {
    File file = new File(strFile);
    if (file.isFile()) {
        addJARLoader(new Object[] { file.toURI().toURL() });
    }
}

From source file:Main.java

public static void deleteDir(File target) {
    if (target.exists() == false) {
        return;/*from   ww  w.j a v a 2 s.  c  o m*/
    }

    if (target.isFile()) {
        target.delete();
    }

    if (target.isDirectory()) {
        File[] files = target.listFiles();
        for (int i = 0; i < files.length; i++) {
            deleteDir(files[i]);
        }
        target.delete();
    }
}

From source file:com.googlecode.hiberpcml.generator.Tool.java

public static ArrayList<File> getFilesToParse(File sourceFile) {
    ArrayList<File> files = new ArrayList<File>();
    if (sourceFile == null || !sourceFile.exists()) {
        return files;
    }//from   w w w .ja va  2  s. com

    if (sourceFile.isDirectory()) {
        for (File file : sourceFile.listFiles()) {
            if (file.isFile() && file.getName().toLowerCase().endsWith(".pcml")) {
                files.add(file);
            }
        }
    } else {
        files.add(sourceFile);
    }

    return files;
}

From source file:com.px100systems.data.utility.BackupFile.java

public static boolean isBackup(File file, String unitName) {
    return file.isFile() && file.getName().endsWith(unitName + EXTENSION);
}

From source file:Main.java

/**
 * @param file/*from   w  w w  .j a v  a 2  s .c o m*/
 * @param includeHiddleFiles
 * @param includeFolder
 * @return
 */
public static int getNumFilesInFolder(File[] files, boolean includeHiddleFiles, boolean includeFolder) {
    int size = 0;
    for (int i = 0; i < files.length; i++) {
        File file = files[i];
        if (file.isFile()) {
            size++;
        } else if (file.isDirectory()) {
            size += getNumFilesInFolder(file, includeHiddleFiles, includeFolder);
        }
    }
    return size;
}

From source file:Main.java

/**
 * install app/*from  w  w w.j  a  va  2s.  c o  m*/
 * 
 * @param context
 * @param filePath
 * @return whether apk exist
 */
public static boolean install(Context context, String filePath) {
    Intent i = new Intent(Intent.ACTION_VIEW);
    File file = new File(filePath);
    if (file != null && file.length() > 0 && file.exists() && file.isFile()) {
        i.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive");
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(i);
        return true;
    }
    return false;
}