projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improved JavaJsonLineCounter a bit
[Mograsim.git]
/
tests
/
net.mograsim.logic.model.am2900.tests
/
src
/
net
/
mograsim
/
logic
/
model
/
JavaJsonLineCounter.java
diff --git
a/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/JavaJsonLineCounter.java
b/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/JavaJsonLineCounter.java
index
7811638
..
de71372
100644
(file)
--- a/
tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/JavaJsonLineCounter.java
+++ b/
tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/JavaJsonLineCounter.java
@@
-3,26
+3,30
@@
package net.mograsim.logic.model;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
public class JavaJsonLineCounter
{
public static void main(String[] args) throws IOException
{
import java.util.stream.StreamSupport;
public class JavaJsonLineCounter
{
public static void main(String[] args) throws IOException
{
- printLineCount("..
\\..", "java
");
- printLineCount("..
\\..", "json
");
+ printLineCount("..
/..", "java", "bin", "classes", "SWTHelper
");
+ printLineCount("..
/..", "json", "bin", "classes", "SWTHelper
");
}
}
- private static void printLineCount(String path, String filetype) throws IOException
+ private static void printLineCount(String path, String filetype
, String... excludedDirectoryNames
) throws IOException
{
{
+ Set<Path> excludedDirectoryPaths = Arrays.stream(excludedDirectoryNames).map(Paths::get).collect(Collectors.toSet());
AtomicLong lineCount = new AtomicLong();
AtomicLong byteSize = new AtomicLong();
AtomicLong fileCount = new AtomicLong();
Files.walk(Paths.get(path)).filter(Files::isRegularFile).filter(p -> p.toString().endsWith('.' + filetype))
AtomicLong lineCount = new AtomicLong();
AtomicLong byteSize = new AtomicLong();
AtomicLong fileCount = new AtomicLong();
Files.walk(Paths.get(path)).filter(Files::isRegularFile).filter(p -> p.toString().endsWith('.' + filetype))
- .filter(p -> !StreamSupport.stream(p.spliterator(), false).anyMatch(Paths.get("bin")::equals))
- .filter(p -> !StreamSupport.stream(p.spliterator(), false).anyMatch(Paths.get("classes")::equals)).forEach(p ->
+ .filter(p -> !StreamSupport.stream(p.spliterator(), false).anyMatch(excludedDirectoryPaths::contains)).forEach(p ->
{
try
{
{
try
{