/* * [Boomerang.java] * * Summary: Program to help test exec. It just echoes in System.in input on out. * * Copyright: (c) 2009-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2009-04-07 initial version */ package com.mindprod.example; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import static java.lang.System.*; /** * Program to help test exec. It just echoes in System.in input on out. *

* I don't think it has any practical application. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2009-04-07 initial version * @since 2009-04-07 */ public class Boomerang { /** * e.g. \n \r\n or \r, whatever system uses to separate lines in a text file. Only used inside multiline fields. The * file itself should use Windows format \r \n, though \n by itself will also work. */ private static final String lineSeparator = System.getProperty( "line.separator" ); /** * echo System.in to out. On EOF shut down. * * @param args not used * * @throws java.io.IOException if trouble setting up reader/writer */ public static void main( String[] args ) throws IOException { // use platform default encoding. final BufferedReader br = new BufferedReader( new InputStreamReader( System.in ), 50 /* keep small for testing */ ); final OutputStreamWriter osw = new OutputStreamWriter( out ); String line; while ( ( line = br.readLine() ) != null ) { osw.write( line ); osw.write( lineSeparator ); } br.close(); osw.close(); } }