我正在尝试用java开发一个程序,它将计算给定文件夹中的文件数以及每个单独文件中的代码行。我目前的代码只能从文件夹中提取一个文件并计算该特定文件的代码行数。请帮助我了解如何从这里开始。
我当前的代码:
public class FileCountLine {
public static void main(String[] args) throws FileNotFoundException {
File file = new File("E:/WalgreensRewardsPosLogSupport.java");
Scanner scanner = new Scanner(file);
int count = 0;
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
count++;
}
System.out.println("Lines in the file: " + count);
}
}