How to redirect input in Powershell without BOM?
问题 I am trying to redirect input in Powershell by Get-Content input.txt | my-program args The problem is the piped UTF-8 text is preceded with a BOM (0xefbbbf), and my program cannot handle that correctly. A minimal working example: // File: Hex.java import java.io.IOException; public class Hex { public static void main(String[] dummy) { int ch; try { while ((ch = System.in.read()) != -1) { System.out.print(String.format("%02X ", ch)); } } catch (IOException e) { } } } Then in powershell javac