java Runtime.getRunTime().exec & wildcards?

后端 未结 5 1257
余生分开走
余生分开走 2020-11-30 08:21

i\'m trying to remove junk files by using

Process p = Runtime.getRuntime().exec();

it works fine as long as i do not use wildcards, i.e. th

5条回答
  •  醉话见心
    2020-11-30 08:28

    Might I suggest that you let Java do this for you?

    • Use file.listFiles() to get the list of files
    • Use file.getName().contains(string) to filter them if needed
    • iterate over the array performing file.delete()

    Advantage: improved portability, saves the cost of an exec()

提交回复
热议问题