Skip to content

Instantly share code, notes, and snippets.

@xerz-one
Last active February 26, 2018 08:17
Show Gist options
  • Save xerz-one/269fee61dcfa0d299a69dd55756ff515 to your computer and use it in GitHub Desktop.
Save xerz-one/269fee61dcfa0d299a69dd55756ff515 to your computer and use it in GitHub Desktop.
A piping thing in Java, pretty dumb
package net.espectalll.Pipe;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.FileInputStream;
public class Main {
public static void read(InputStreamReader stream) {
try {
BufferedReader stdin = new BufferedReader(stream);
for (String input; (input = stdin.readLine()) != null;)
System.out.println(input);
}
catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
if (args.length == 0) read(new InputStreamReader(System.in));
for (String arg : args) {
try {
read(new InputStreamReader(
(arg.equals("-") ? System.in : new FileInputStream(arg))));
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment