切换风格

默认Lavender Sky Flowers Wizard Snow Beige California City Dragon Black London Sunset glow Pink Cloud

2

主题

24

积分

0

精华

用户组 

易积分
3
热心
0
好评
0
如何在已root的设备上搜索指定文件[复制链接]
发表于 5 小时前 | 显示全部楼层 |阅读模式
20易积分

大哥们    如何在已root的设备上搜索指定文件  

比如对这个路径 /data/data/com.tencent.mm/     进行搜索haoren.txt 文件 ,搜到之后输出路径

帮我写一个简单的例子  ,谢谢

易如意中文编程学习交流论坛有你更精彩~
回复

使用道具 举报

2

主题

314

积分

0

精华

用户组 

易积分
35
热心
0
好评
2
发表于 3 小时前 | 显示全部楼层
import java.io.File;

    public static void searchFile(File dir, String targetName) {
        if (dir.isDirectory()) {
            File[] files = dir.listFiles();
            if (files != null) {
                for (File file : files) {
                    if (file.isDirectory()) {
                        searchFile(file, targetName);
                    } else if (file.getName().equals(targetName)) {
                        System.out.println("找到文件: " + file.getAbsolutePath());
                    }
                }
            }
        }
    }
'---------------调用方法
    public static void main(String[] args) {
        String targetPath = "/data/data/com.tencent.mm/";
        String targetFile = "haoren.txt";
        searchFile(new File(targetPath), targetFile);
    }
易如意中文编程学习交流论坛有你更精彩~
回复

使用道具 举报

2

主题

24

积分

0

精华

用户组 

易积分
3
热心
0
好评
0
发表于 7 分钟前 | 显示全部楼层
asd708820274 发表于 2025-6-27 03:38
import java.io.File;

    public static void searchFile(File dir, String targetName) {

大哥,冒昧问一下  E4A不是中文的吗
易如意中文编程学习交流论坛有你更精彩~
回复

使用道具 举报

QQ|sitemap|免责声明|RGB颜色对照表|手机版|小黑屋| 易如意 - E4A中文编程学习交流论坛

GMT+8, 2025-6-27 06:41 , Processed in 0.082578 second(s), 29 queries .

Powered by Discuz! X3.4

© 2001-2018 eruyi.cn

返回顶部