Hi i'm trying to create an if statement that checks the size of a file here's what i have although it's not working.
File file = new File("/path/to/file.zip");
long fileSize = file.length();
if (!(fileSize > 0));{
Toast.makeText(MainMetho开发者_如何转开发d.this, "Equal to 0", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(MainMethod.this, "Greater than 0", Toast.LENGTH_LONG).show();
}
You have a semicolon at the end of your IF statement which is causing the problem here.
There is a semicolon at the end of your if statement. Also, you can simplify the code somewhat by doing the following:
if (file.length() > 0)
System.out.println("File Greater than 0");
else
System.out.println("File LessThanEqual to 0");
Just my opinion
精彩评论