Android java:如何使用if-then-else [英] Android java: how to use if-then-else
本文介绍了Android java:如何使用if-then-else的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i想这样做
如果file.txt不存在
然后做
startDownload( );
readFile();
else delete file.txt
解决方案
一些代码可以尝试:
文件f = new File(filePathString);
if(!f.exists()&!f.isDirectory()){
startDownload();
readFile();
}
else {
try {
file.delete();
} catch(Exception e){
e.printStackTrace();
}
}
i'm using eclipse with ADT plugin, and i'm developing an app where i want to use if then and else. i want to do this
if file.txt not exist
then do
startDownload();
readFile();
else delete file.txt
解决方案
Here is some code to try:
File f = new File(filePathString);
if(!f.exists() && !f.isDirectory()) {
startDownload();
readFile();
}
else {
try {
file.delete();
} catch (Exception e) {
e.printStackTrace();
}
}
这篇关于Android java:如何使用if-then-else的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文