Use pipe .
This trivial Java application simply prints lines from stdin:
public class Dump {
public static void main(String[] args) {
java.util.Scanner scanner = new java.util.Scanner(System.in);
int line = 0;
while (scanner.hasNextLine()) {
System.out.format("%d: %s%n", line++, scanner.nextLine());
}
}
}
Called with this batch file:
@ECHO OFF
(ECHO This is line one
ECHO This is line two; the next is empty
ECHO.
ECHO This is line four)| java -cp bin Dump
PAUSE
... he will print:
0: This is line one
1: This is line two; the next is empty
2:
3: This is line four
source
share