80,471
社区成员




File[] sonFile = file.listFiles();
for (int i = 0; i < sonFile.length; i++)
{
if (sonFile[i].isFile())
{
}
else if (sonFile[i].isDirectory())
{
}
else
{
//http://bbs.csdn.net/topics/310088039
if(sonFile[i].exists())
{}
else
{
Log.e("-->",sonFile[i].getName());
Log.e("-->",sonFile[i].getPath());
}
}
}
.android_secure
的特殊性可以 通过百度它本身得到解决
那就结贴了,
这个问题问的真是坑
就是心不静早知道自己百度一波就好了我当时肯定是蒙圈了。
package a114.yangming.myview;
import android.util.Log;
import java.io.File;
/**
* Created by Tom on 2016/3/12.
*/
public class TestBug
{
String path = "/storage/sdcard1/.android_secure";
String sdCardPath = "/storage/sdcard1/";
public void ifFileExists()
{
File sdCard = new File(this.sdCardPath);
File[] sdCardSons = sdCard.listFiles();
for (File value : sdCardSons)
{
if (value.getPath().equals(this.path))
{
Log.e("测试", "遍历得到的路径为:" + value.getPath());
Log.e("测试", "这说明不是排序模块的问题");
testMySelf(value);
}
}
}
public void testMySelf(File file)
{
File testFile;
if (file == null)
{
testFile = new File("/这个路径/天马/行空");
}
else
{
testFile = file;
}
if (testFile.isFile())
{
Log.e("测试", "扯淡路径被判断为--->文件===" + testFile.getPath());
}
else if (testFile.isDirectory())
{
Log.e("测试", "扯淡路径被判断为-->文件夹===" + testFile.getPath());
}
else
{
if (testFile.exists())
{
Log.e("测试", "扯淡路径被判断为-->存在===" + testFile.getPath());
}
else
{
Log.e("测试", "扯淡路径被判断为-->不存在===" + testFile.getPath());
}
}
}
}
//执行:
TestBug test = new TestBug();
test.ifFileExists();
test.testMySelf(null);
结果:
E/测试: 遍历得到的路径为:/storage/sdcard1/.android_secure
E/测试: 这说明不是排序模块的问题
E/测试: 扯淡路径被判断为-->不存在===/storage/sdcard1/.android_secure
E/测试: 扯淡路径被判断为-->不存在===/这个路径/天马/行空