安卓;检查文件是否存在而不创建新文件 [英] Android; Check if file exists without creating a new one
本文介绍了安卓;检查文件是否存在而不创建新文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想检查我的包文件夹中是否存在文件,但我不想创建一个新的.
I want to check if file exists in my package folder, but I don't want to create a new one.
File file = new File(filePath);
if(file.exists())
return true;
此代码是否在不创建新文件的情况下进行检查?
Does this code check without creating a new file?
推荐答案
你的代码块不会创建一个新的,它只检查它是否已经存在,而没有其他任何东西.
Your chunk of code does not create a new one, it only checks if its already there and nothing else.
File file = new File(filePath);
if(file.exists())
//Do something
else
// Do something else.
这篇关于安卓;检查文件是否存在而不创建新文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文