Java reads text file with extra whitespace and CRLF

feadsimildisy

New Member
I have a text file generated by PowerShell using the command\[code\]GetChild-Item C:\Source\Path | ForEach-Object { $_.Name } > "C:\MyPlace\outfile.txt"\[/code\]This generates \[code\]outfile.txt\[/code\] which opens like this Notepad++
GYcDB.jpg
but when opened in Java and read line by line like so:\[code\]while((line = br.readLine()) != null) { line = line.replaceAll("\\s", ""); System.out.println(i + ":\t" + line);}\[/code\]It produces this:
ipHgb.png
Which totally garbles my processing. I've tried replacing whitespace characters but it doesn't seem to be doing the trick. Any ideas?
 
Back
Top