本文整理汇总了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);
}
}
示例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();
}
}
}
示例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);
}
示例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();
}
}
示例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;
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}
}
}
示例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();// 删除目录本身
}
示例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;
}
示例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
};
}
示例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;
}
}
示例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);
}
}
}
}
}
}
}
}