當前位置: 首頁>>代碼示例>>Java>>正文


Java File.isFile方法代碼示例

本文整理匯總了Java中java.io.File.isFile方法的典型用法代碼示例。如果您正苦於以下問題:Java File.isFile方法的具體用法?Java File.isFile怎麽用?Java File.isFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.File的用法示例。


在下文中一共展示了File.isFile方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readFromSystemPath

import java.io.File; //導入方法依賴的package包/類
/**
 * 從操作係統路徑中加載配置文件
 * @param filePath filePath
 * @throws IOException  IOException
 * @throws FileNotFoundException  FileNotFoundException
 * @throws DocumentException  DocumentException
 * @throws SAXException SAXException
 */
public void readFromSystemPath(String filePath) throws FileNotFoundException, 
	IOException, DocumentException, SAXException
{
	configFile = new File(filePath);
	if(!configFile.isFile())
	{
		throw new ConfigException(String.format("Target file [%s] is not a file.", filePath), "");
	}
	else if(!filePath.endsWith(".xml"))
	{
		logger.warn("Target file [%s] is not end with .xml", filePath);
	}
	
	try(InputStream configInput = new FileInputStream(configFile))
	{
		read(configInput);
	}
}
 
開發者ID:LinuxSuRen,項目名稱:phoenix.webui.framework,代碼行數:27,代碼來源:Phoenix.java

示例2: clearAids

import java.io.File; //導入方法依賴的package包/類
public void clearAids()
{
    mAidList.clear();
    max_qpboc_offline_limit = 0;
    max_qpboc_trans_limit = 0;
    max_qpboc_cvm_limit = 0;

    String path = mDataPath + "/" + EMVAid._aids_folder;

    File file = new File(path);
    File[] aidList = file.listFiles();

    if(aidList == null) return;

    LogUtil.i(TAG,"" + path + "files count = " + aidList.length);

    for (File f : aidList) {
        if (f.isFile()) {
            LogUtil.i(TAG,"Delete Aid - " + f.getAbsolutePath());
            f.delete();
        }
    }
}
 
開發者ID:changingp,項目名稱:qpboc-kata,代碼行數:24,代碼來源:EMVParam.java

示例3: checkForExistingCodestyles

import java.io.File; //導入方法依賴的package包/類
private void checkForExistingCodestyles() {
    File[] files = new File(getCodestylePath()).listFiles();

    // File is not a directory
    if(files == null) {
        return;
    }

    ArrayList<File> copyFiles = new ArrayList<>();
    for (File file : files) {
        if (file.isFile() && isXMLFileExtension(file.getName())) {
            copyFiles.add(file);
        }
    }
    copyFiles(copyFiles);
}
 
開發者ID:DanielMartinus,項目名稱:IntelliJ-codestyle-sync,代碼行數:17,代碼來源:CodeStyleManager.java

示例4: Variable

import java.io.File; //導入方法依賴的package包/類
public Variable(String name, String location) {
    this.name = name;
    this.location = location;
    File f = new File(location);
    fileVar = f.exists() && f.isFile();
    if (fileVar) {
        file = f.getName();
        this.location = f.getParentFile().getAbsolutePath();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:Workspace.java

示例5: loadFromFile

import java.io.File; //導入方法依賴的package包/類
/**
 * Attempts to load the settings file from the file parameter.
 * <p>
 * NOTE: This will load the default settings configuration if it fails to load.
 *
 * @param file
 * 		settings file
 *
 * @return True if successfully loaded file, false otherwise.
 */
public static final boolean loadFromFile( File file )
{
	if ( !file.isFile() )
	{
		loadFromDefaultSettings();
		return false;
	}

	try
	{
		String fileContents = FileUtils.readFileToString(file);
		JSONObject jsonFile = new JSONObject(fileContents);

		parseJSONSettings(jsonFile, "");

		if ( settings.isEmpty() )
		{
			loadFromDefaultSettings();
			return false;
		} else
			return true;
	}
	catch ( IOException e )
	{
		loadFromDefaultSettings();
		return false;
	}
}
 
開發者ID:dhawal9035,項目名稱:WebPLP,代碼行數:39,代碼來源:ApplicationSettings.java

示例6: loadLibs

import java.io.File; //導入方法依賴的package包/類
private void loadLibs(File[] fs, List<File> al) {
    for (int i = 0; i < fs.length; i++) {
        File c = fs[i];
        if (c.isFile()) {
            String name = c.getName().toLowerCase();
            if ((name.endsWith(".jar")) && (c.isFile())) {
                al.add(c);
            }
        } else if ((c.isDirectory()) && (!c.getName().equals(".."))
                && (!c.getName().equals("."))) {
            loadLibs(c.listFiles(), al);
        }
    }
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:15,代碼來源:WebStartClient.java

示例7: install

import java.io.File; //導入方法依賴的package包/類
/**
 * 調用係統安裝應用
 */
public static boolean install(Context context, File file) {
    if (file == null || !file.exists() || !file.isFile()) {
        return false;
    }
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
    return true;
}
 
開發者ID:jeasinlee,項目名稱:AndroidBasicLibs,代碼行數:14,代碼來源:PackageUtil.java

示例8: copyResourceFolder

import java.io.File; //導入方法依賴的package包/類
public static void copyResourceFolder(String resourceFolder, String destDir)
		throws IOException {
	final File jarFile = new File(Util.class.getProtectionDomain()
			.getCodeSource().getLocation().getPath());
	if (jarFile.isFile()) { // Run with JAR file
		resourceFolder = StringUtils.strip(resourceFolder, "/");
		final JarFile jar = new JarFile(jarFile);
		// gives ALL entries in jar
		final Enumeration<JarEntry> entries = jar.entries();
		while (entries.hasMoreElements()) {
			JarEntry element = entries.nextElement();
			final String name = element.getName();
			// filter according to the path
			if (name.startsWith(resourceFolder + "/")) {
				String resDestDir = Util.combineFilePath(destDir,
						name.replaceFirst(resourceFolder + "/", ""));
				if (element.isDirectory()) {
					File newDir = new File(resDestDir);
					if (!newDir.exists()) {
						boolean mkdirRes = newDir.mkdirs();
						if (!mkdirRes) {
							logger.error("Failed to create directory "
									+ resDestDir);
						}
					}
				} else {
					InputStream inputStream = null;
					try {
						inputStream = Util.class.getResourceAsStream("/"
								+ name);
						if (inputStream == null) {
							logger.error("No resource is found:" + name);
						} else {
							Util.outputFile(inputStream, resDestDir);
						}

						/* compress js files */
						inputStream = Util.class.getResourceAsStream("/"
								+ name);
						compressor.compress(inputStream, name, destDir);
					} finally {
						if (inputStream != null) {
							inputStream.close();
						}
					}
				}
			}
		}
		jar.close();
	} else { // Run with IDE
		final URL url = Util.class.getResource(resourceFolder);
		if (url != null) {
			try {
				final File src = new File(url.toURI());
				File dest = new File(destDir);
				FileUtils.copyDirectory(src, dest);
				Util.compressFilesInDir(src, destDir);
			} catch (URISyntaxException ex) {
				logger.error(ex);
			}
		}
	}
}
 
開發者ID:WinRoad-NET,項目名稱:wrdocletbase,代碼行數:64,代碼來源:Util.java

示例9: goMinusR

import java.io.File; //導入方法依賴的package包/類
/** Tries to set permissions on preferences storage file to -rw------- */
public static void goMinusR(Preferences p) {
    File props = new File(Places.getUserDirectory(), ("config/Preferences" + p.absolutePath()).replace('/', File.separatorChar) + ".properties");
    if (props.isFile()) {
        props.setReadable(false, false); // seems to be necessary, not sure why
        props.setReadable(true, true);
        LOG.log(Level.FINE, "chmod go-r {0}", props);
    } else {
        LOG.log(Level.FINE, "no such file to chmod: {0}", props);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:Utils.java

示例10: recurse

import java.io.File; //導入方法依賴的package包/類
private static void recurse(File dir, Set<File> foundFiles) {
    for (File f : dir.listFiles()) {
        if (f.isFile()) {
            foundFiles.add(f);
        } else if (f.isDirectory()) {
            recurse(f, foundFiles);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:JavacState.java

示例11: deleteDir

import java.io.File; //導入方法依賴的package包/類
public static void deleteDir(String path) {
	File dir = new File(path);
	if (dir == null || !dir.exists() || !dir.isDirectory())
		return;
	
	for (File file : dir.listFiles()) {
		if (file.isFile())
			file.delete(); // 刪除所有文件
		else if (file.isDirectory())
			deleteDir(path); // 遞規的方式刪除文件夾
	}
	dir.delete();// 刪除目錄本身
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:14,代碼來源:FileUtils.java

示例12: listOfShaders

import java.io.File; //導入方法依賴的package包/類
static ArrayList listOfShaders()
{
    ArrayList<String> arraylist = new ArrayList();
    arraylist.add(packNameNone);
    arraylist.add(packNameDefault);

    try
    {
        if (!shaderpacksdir.exists())
        {
            shaderpacksdir.mkdir();
        }

        File[] afile = shaderpacksdir.listFiles();

        for (int i = 0; i < afile.length; ++i)
        {
            File file1 = afile[i];
            String s = file1.getName();

            if (file1.isDirectory())
            {
                File file2 = new File(file1, "shaders");

                if (file2.exists() && file2.isDirectory())
                {
                    arraylist.add(s);
                }
            }
            else if (file1.isFile() && s.toLowerCase().endsWith(".zip"))
            {
                arraylist.add(s);
            }
        }
    }
    catch (Exception var6)
    {
        ;
    }

    return arraylist;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:43,代碼來源:Shaders.java

示例13: getDirectoryContent

import java.io.File; //導入方法依賴的package包/類
public int[] getDirectoryContent(File file, String filter) {
    boolean hasFilter = false;
    int files = 0;
    int directories = 0;

    if (filter != null) {
        hasFilter = true;
    }

    File[] listFiles = file.listFiles();
    if (listFiles != null) {
        for (File f : listFiles) {
            if (f.isHidden())
                continue;
            if (f.isFile()) {
                if (!filePathsFiltered.contains(f.getPath())) {
                    if (hasFilter) {
                        String fullName = f.getName();
                        int dotPos = fullName.lastIndexOf('.');
                        if (dotPos >= 0 && dotPos < fullName.length()) {
                            String mimeType = MimeUtils.guessMimeTypeFromExtension(fullName.substring(dotPos + 1).toLowerCase()); 
                            if (mimeType != null){
                                String [] filters = filter.split("\\|\\|");
                                for(String filt: filters){
                                    if(mimeType.startsWith(filt)&&!filt.isEmpty()){
                                        files++;
                                    }

                                }
                            }


                        }
                    } else {
                        files++;
                    }
                }
            } else if (!dirNamesFiltered.contains(f.getName())
                    && !dirPathsFiltered.contains(f.getPath()))
                directories++;
        }
    }

    return new int[] {
            directories, files
    };
}
 
開發者ID:archos-sa,項目名稱:aos-FileCoreLibrary,代碼行數:48,代碼來源:FileManagerCore.java

示例14: readCsvFile

import java.io.File; //導入方法依賴的package包/類
public static Map readCsvFile(String filePath) {
	try {
		Map userMap = new HashMap();
		int i = 0;
		int row = 0;
		String username = "";
		String geo = "";
		String room = "";
		String encoding = "GBK";
		File file = new File(filePath);
		if (file.isFile() && file.exists()) {
			InputStreamReader read = new InputStreamReader(new DataInputStream(new FileInputStream(file)),
					encoding);
			BufferedReader bufferedReader = new BufferedReader(read);
			String lineTxt = null;
			while ((lineTxt = bufferedReader.readLine()) != null) {
				row++;
				String[] lineArr = lineTxt.split(",");
				if (lineTxt.contains("order")) {
					username = lineArr[0];
				} else if (lineTxt.contains("geog")) {
					if (lineArr.length <= 6) {
						for (i = 1; i < lineArr.length; ++i) {
							geo = geo + "," + lineArr[i];
						}
						for (i = 1; i <= 6 - lineArr.length; ++i) {
							geo = geo + "," + "0";
						}
					} else {
						for (i = lineArr.length - 5; i <= lineArr.length - 1; ++i) {
							geo = geo + "," + lineArr[i];
						}
					}
					geo = geo.substring(1);
				} else if (lineTxt.contains("room")) {
					for (i = 1; i < lineArr.length; ++i) {
						room = room + "," + lineArr[i];
					}
					room = room.substring(1);
				}
				if (row % 3 == 0) {
					userMap.put(username, geo + "\t" + room);
					geo = "";
					room = "";
				}
			}
			read.close();
			return userMap;
		} else {
			System.out.println("�Ҳ���ָ�����ļ�");
			return null;
		}
	} catch (Exception e) {
		System.out.println("��ȡ�ļ����ݳ���");
		e.printStackTrace();
		return null;
	}
}
 
開發者ID:liuxuanhai,項目名稱:WeiXing_xmu-2016-MrCode,代碼行數:59,代碼來源:Center_Vector_Create.java

示例15: addNativeLibraries

import java.io.File; //導入方法依賴的package包/類
/**
 * Adds the native libraries from the top native folder.
 * The content of this folder must be the various ABI folders.
 *
 * This may or may not copy gdbserver into the apk based on whether the debug mode is set.
 *
 * @param nativeFolder the native folder.
 *
 * @throws ApkCreationException if an error occurred
 * @throws SealedApkException if the APK is already sealed.
 * @throws DuplicateFileException if a file conflicts with another already added to the APK
 *                                   at the same location inside the APK archive.
 *
 * @see #setDebugMode(boolean)
 */
public void addNativeLibraries(File nativeFolder)
        throws ApkCreationException, SealedApkException, DuplicateFileException {
    if (mIsSealed) {
        throw new SealedApkException("APK is already sealed");
    }

    if (!nativeFolder.isDirectory()) {
        // not a directory? check if it's a file or doesn't exist
        if (nativeFolder.exists()) {
            throw new ApkCreationException("%s is not a folder", nativeFolder);
        } else {
            throw new ApkCreationException("%s does not exist", nativeFolder);
        }
    }

    File[] abiList = nativeFolder.listFiles();

    verbosePrintln("Native folder: %s", nativeFolder);

    if (abiList != null) {
        for (File abi : abiList) {
            if (abi.isDirectory()) { // ignore files

                File[] libs = abi.listFiles();
                if (libs != null) {
                    for (File lib : libs) {
                        // only consider files that are .so or, if in debug mode, that
                        // are gdbserver executables
                        if (lib.isFile() &&
                                (PATTERN_NATIVELIB_EXT.matcher(lib.getName()).matches() ||
                                PATTERN_BITCODELIB_EXT.matcher(lib.getName()).matches() ||
                                        (mDebugMode &&
                                                SdkConstants.FN_GDBSERVER.equals(
                                                        lib.getName())))) {
                            String path =
                                SdkConstants.FD_APK_NATIVE_LIBS + "/" +
                                abi.getName() + "/" + lib.getName();

                            try {
                                doAddFile(lib, path);
                            } catch (IOException e) {
                                mBuilder.cleanUp();
                                throw new ApkCreationException(e, "Failed to add %s", lib);
                            }
                        }
                    }
                }
            }
        }
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:67,代碼來源:ApkBuilder.java


注:本文中的java.io.File.isFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。