的代码基本上可以让用户输入他们想删除这是在变量“catName”举行,然后执行,试图找到下面的代码文件的名称并删除它的路径。但是,它似乎不起作用,因为它不会以这种方式删除文件。但是,如果我输入整个路径,是删除文件。查找路径在运行时删除文件
File file = new File(catName + ".txt");
String path = file.getCanonicalPath();
File filePath = new File(path);
filePath.delete();