Last active
February 26, 2018 08:17
-
-
Save xerz-one/269fee61dcfa0d299a69dd55756ff515 to your computer and use it in GitHub Desktop.
A piping thing in Java, pretty dumb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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