Skip to content

Conversation

@labkey-chrisj
Copy link
Contributor

Rationale

This change adds a method to testFileUtils that returns the number of lines in a file, without loading the whole file into memory

Related Pull Requests

LabKey/platform#7040

}
}

public static int getFileRowCount(final File file) throws IOException
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe should return a long?

Comment on lines 125 to 130
try (BufferedReader reader = new BufferedReader(new FileReader(file)))
{
int lines = 0;
while (reader.readLine() != null) lines++;
return lines;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

    try (Stream<String> lines = Files.lines(file.toPath())) {
        return lines.count();
    }

@labkey-chrisj labkey-chrisj merged commit 470a22e into develop Sep 17, 2025
6 checks passed
@labkey-chrisj labkey-chrisj deleted the fb_export_search_index branch September 17, 2025 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants