I've written a utility in Java that filters JSON input, from a file or from stdin, to XML. Though I've made it a stand-alone, runnable JAR, I'm lost as to how to redirect input to it via stdin. For example:
cat sample.json | java -jar ./target/json-to-xml-1.0.0.jar
This command line doesn't work; I wonder if this can even be done.
private static String readContentFromStdIn() throws IOException
{
char ch;
StringBuilder sb = new StringBuilder();
PipedInputStream input = new PipedInputStream();
while( ( ch = ( char ) input.read() ) != -1 )
sb.append( ch );
input.close();
return sb.toString();
}
System.in? (please paste the relevant code)