I have an issue with this line of code :
Map<String, Long> wordCounts = Files.lines(Paths.get(fileSource))
.flatMap(line -> pattern.splitAsStream(line))
.collect(Collectors.groupingBy(String::toLowerCase,
TreeMap::new, Collectors.counting()));
If I run from Intellij it works fine.
If I package my application (Maven) and run it with :
java -jar myapp.war
I am getting this error :
Caused by: java.nio.charset.MalformedInputException: Input length = 1
I don't know why.
[UPDATE] This way, the file is being created.
Path path = Paths.get(newTxtName);
try {
BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8);
writer.append(parsedDocx);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
But there is something wrong with this line when I execute the war file on a different Server(windows 10 family) (not my pc) :
Map<String, Long> wordCounts = Files.lines(Paths.get(fileSource), Charset.forName("UTF-8"))
I get a
java.nio.file.AccessDeniedException: <fileName>
It works fine on my computer (windows 10 family) though, with the same war.