【发布时间】:2021-01-12 14:21:41
【问题描述】:
我有以下目录server/auth/usernames.txt,我想读取所有行并找到名为clientusername的字符串的特定索引
我有以下代码
File dirFile = new File("auth/");
String clientUsername ="john";
int indexUsername = Files.readAllLines(Paths.get(dirFile.getAbsolutePath() + "usernames.txt")).indexOf(clientUsername);
但这给了我server/auth/usernames.txt 的完整路径。我只想得到auth/usernames.txt。如何做到这一点?
【问题讨论】: