I have a text file generated by PowerShell using the command
GetChild-Item C:\Source\Path | ForEach-Object { $_.Name } > "C:\MyPlace\outfile.txt"
This generates outfile.txt which opens like this Notepad++

but when opened in Java and read line by line like so:
while((line = br.readLine()) != null) {
line = line.replaceAll("\\s", "");
System.out.println(i + ":\t" + line);
}
It produces this:

Which totally garbles my processing. I’ve tried replacing whitespace characters but it doesn’t seem to be doing the trick. Any ideas?
The problem appears to be that Powershell is emitting a file with a unicode encoding but Java is reading it as plain old ASCII. You need to change the java code to read the file as unicode.