Example usage for java.io PrintStream println

List of usage examples for java.io PrintStream println

Introduction

In this page you can find the example usage for java.io PrintStream println.

Prototype

public void println(Object x) 

Source Link

Document

Prints an Object and then terminate the line.

Usage

From source file:edu.oregonstate.eecs.mcplan.domains.blackjack.Experiments.java

/**
 * @param args/*w  w w  . j  av a 2  s.  c o  m*/
 * @throws FileNotFoundException
 */
public static void main(final String[] args) throws FileNotFoundException {
    final PrintStream data_out = new PrintStream("data_r2.csv");
    data_out.println("abstraction,game,Ngames,Nepisodes,p,mean,var,conf");
    final BlackjackParameters params = new BlackjackParameters();
    final BlackjackMdp mdp = new BlackjackMdp(params);
    System.out.println("Solving MDP");
    final Pair<String[][], String[][]> soln = mdp.solve();
    final String[][] hard_actions = soln.first;
    final String[][] soft_actions = soln.second;

    //      for( final int Nepisodes : new int[] { 512, 1024 } ) {
    //         runExperiment( new IdentityRepresenter(), Nepisodes, 0.0, Ngames, data_out );
    //         runExperiment( new BlackjackAggregator(), Nepisodes, 0.0, Ngames, data_out );
    //         runExperiment( new NoisyAStarAggregator( rng, 0.0 ), Nepisodes, 0.0, Ngames, data_out );
    //      }

    //      for( final int Nepisodes : new int[] { 4, 8, 16, 32, 64, 128, 256, 512, 1024 } ) {
    //         for( final double p : new double[] { 0.02, 0.04, 0.08, 0.16, 0.32 } ) {
    //            runExperiment( new NoisyAStarAggregator( rng, p ), Nepisodes, p, Ngames, data_out );
    //         }
    //      }

    final int Ngames = 100000;
    for (final int Nepisodes : new int[] { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192 }) {
        //      for( final int Nepisodes : new int[] { 8192 } ) {
        for (final double p : new double[] { 0, 0.3 }) {
            runExperiment(new NoisyAStarAggregator(rng, p, hard_actions, soft_actions, params), params,
                    Nepisodes, p, Ngames, data_out);
        }

        runExperiment(new BlackjackAggregator(), params, Nepisodes, 0.0, Ngames, data_out);
        runExperiment(new BlackjackPrimitiveRepresenter(), params, Nepisodes, 0.0, Ngames, data_out);
    }
}

From source file:org.alfresco.filesys.NFSServerBean.java

/**
 * Runs the NFS server directly/*from  www  .j  a v a  2s  .c o  m*/
 * 
 * @param args String[]
 */
public static void main(String[] args) {
    PrintStream out = System.out;

    out.println("NFS Server Test");
    out.println("----------------");

    try {
        // Create the configuration service in the same way that Spring creates it

        ApplicationContext ctx = new ClassPathXmlApplicationContext("alfresco/application-context.xml");

        // Get the NFS server bean

        NFSServerBean server = (NFSServerBean) ctx.getBean("nfsServer");
        if (server == null) {
            throw new AlfrescoRuntimeException("Server bean 'nfsServer' not defined");
        }

        // Stop the FTP server, if running

        NetworkServer srv = server.getConfiguration().findServer("FTP");
        if (srv != null)
            srv.shutdownServer(true);

        // Stop the CIFS server, if running

        srv = server.getConfiguration().findServer("SMB");
        if (srv != null)
            srv.shutdownServer(true);

        // Only wait for shutdown if the NFS server is enabled

        if (server.getConfiguration().hasConfigSection(NFSConfigSection.SectionName)) {

            // NFS server should have automatically started
            // Wait for shutdown via the console

            out.println("Enter 'x' to shutdown ...");
            boolean shutdown = false;

            // Wait while the server runs, user may stop the server by typing a key

            while (shutdown == false) {

                // Wait for the user to enter the shutdown key

                int ch = System.in.read();

                if (ch == 'x' || ch == 'X')
                    shutdown = true;

                synchronized (server) {
                    server.wait(20);
                }
            }

            // Stop the server

            server.stopServer();
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    System.exit(1);
}

From source file:cc.twittertools.search.api.SearchStatusesThrift.java

@SuppressWarnings("static-access")
public static void main(String[] args) throws Exception {
    Options options = new Options();

    options.addOption(new Option(HELP_OPTION, "show help"));
    options.addOption(OptionBuilder.withArgName("string").hasArg().withDescription("host").create(HOST_OPTION));
    options.addOption(OptionBuilder.withArgName("port").hasArg().withDescription("port").create(PORT_OPTION));
    options.addOption(//w ww  .j av  a  2  s  . com
            OptionBuilder.withArgName("string").hasArg().withDescription("query id").create(QID_OPTION));
    options.addOption(
            OptionBuilder.withArgName("string").hasArg().withDescription("query text").create(QUERY_OPTION));
    options.addOption(
            OptionBuilder.withArgName("string").hasArg().withDescription("runtag").create(RUNTAG_OPTION));
    options.addOption(OptionBuilder.withArgName("num").hasArg().withDescription("maxid").create(MAX_ID_OPTION));
    options.addOption(OptionBuilder.withArgName("num").hasArg().withDescription("number of results to return")
            .create(NUM_RESULTS_OPTION));
    options.addOption(
            OptionBuilder.withArgName("string").hasArg().withDescription("group id").create(GROUP_OPTION));
    options.addOption(
            OptionBuilder.withArgName("string").hasArg().withDescription("access token").create(TOKEN_OPTION));
    options.addOption(new Option(VERBOSE_OPTION, "print out complete document"));

    CommandLine cmdline = null;
    CommandLineParser parser = new GnuParser();
    try {
        cmdline = parser.parse(options, args);
    } catch (ParseException exp) {
        System.err.println("Error parsing command line: " + exp.getMessage());
        System.exit(-1);
    }

    if (cmdline.hasOption(HELP_OPTION) || !cmdline.hasOption(HOST_OPTION) || !cmdline.hasOption(PORT_OPTION)) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(SearchStatusesThrift.class.getName(), options);
        System.exit(-1);
    }

    String qid = cmdline.hasOption(QID_OPTION) ? cmdline.getOptionValue(QID_OPTION) : DEFAULT_QID;
    String query = cmdline.hasOption(QUERY_OPTION) ? cmdline.getOptionValue(QUERY_OPTION) : DEFAULT_Q;
    String runtag = cmdline.hasOption(RUNTAG_OPTION) ? cmdline.getOptionValue(RUNTAG_OPTION) : DEFAULT_RUNTAG;
    long maxId = cmdline.hasOption(MAX_ID_OPTION) ? Long.parseLong(cmdline.getOptionValue(MAX_ID_OPTION))
            : DEFAULT_MAX_ID;
    int numResults = cmdline.hasOption(NUM_RESULTS_OPTION)
            ? Integer.parseInt(cmdline.getOptionValue(NUM_RESULTS_OPTION))
            : DEFAULT_NUM_RESULTS;
    boolean verbose = cmdline.hasOption(VERBOSE_OPTION);

    String group = cmdline.hasOption(GROUP_OPTION) ? cmdline.getOptionValue(GROUP_OPTION) : null;
    String token = cmdline.hasOption(TOKEN_OPTION) ? cmdline.getOptionValue(TOKEN_OPTION) : null;
    TrecSearchThriftClient client = new TrecSearchThriftClient(cmdline.getOptionValue(HOST_OPTION),
            Integer.parseInt(cmdline.getOptionValue(PORT_OPTION)), group, token);

    System.err.println("qid: " + qid);
    System.err.println("q: " + query);
    System.err.println("max_id: " + maxId);
    System.err.println("num_results: " + numResults);

    PrintStream out = new PrintStream(System.out, true, "UTF-8");

    List<TResult> results = client.search(query, maxId, numResults);
    int i = 1;
    for (TResult result : results) {
        out.println(String.format("%s Q0 %d %d %f %s", qid, result.id, i, result.rsv, runtag));
        if (verbose) {
            System.out.println("# " + result.toString().replaceAll("[\\n\\r]+", " "));
        }
        i++;
    }
    out.close();
}

From source file:fr.cs.examples.conversion.PropagatorConversion.java

/** Program entry point.
 * @param args program arguments (unused here)
 *///  w w  w  .j  a v  a  2 s.co  m
public static void main(String[] args) {
    try {

        // configure Orekit
        Autoconfiguration.configureOrekit();

        // gravity field
        NormalizedSphericalHarmonicsProvider provider = GravityFieldFactory.getNormalizedProvider(2, 0);
        double mu = provider.getMu();

        // inertial frame
        Frame inertialFrame = FramesFactory.getEME2000();

        // Initial date
        AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());

        // Initial orbit (GTO)
        final double a = 24396159; // semi major axis in meters
        final double e = 0.72831215; // eccentricity
        final double i = FastMath.toRadians(7); // inclination
        final double omega = FastMath.toRadians(180); // perigee argument
        final double raan = FastMath.toRadians(261); // right ascention of ascending node
        final double lM = 0; // mean anomaly
        Orbit initialOrbit = new KeplerianOrbit(a, e, i, omega, raan, lM, PositionAngle.MEAN, inertialFrame,
                initialDate, mu);
        final double period = initialOrbit.getKeplerianPeriod();

        // Initial state definition
        final SpacecraftState initialState = new SpacecraftState(initialOrbit);

        // Adaptive step integrator with a minimum step of 0.001 and a maximum step of 1000
        final double minStep = 0.001;
        final double maxStep = 1000.;
        final double dP = 1.e-2;
        final OrbitType orbType = OrbitType.CARTESIAN;
        final double[][] tol = NumericalPropagator.tolerances(dP, initialOrbit, orbType);
        final AbstractIntegrator integrator = new DormandPrince853Integrator(minStep, maxStep, tol[0], tol[1]);

        // Propagator
        NumericalPropagator numProp = new NumericalPropagator(integrator);
        numProp.setInitialState(initialState);
        numProp.setOrbitType(orbType);

        // Force Models:
        // 1 - Perturbing gravity field (only J2 is considered here)
        ForceModel gravity = new HolmesFeatherstoneAttractionModel(
                FramesFactory.getITRF(IERSConventions.IERS_2010, true), provider);

        // Add force models to the propagator
        numProp.addForceModel(gravity);

        // Propagator factory
        PropagatorBuilder builder = new KeplerianPropagatorBuilder(mu, inertialFrame, OrbitType.KEPLERIAN,
                PositionAngle.TRUE);

        // Propagator converter
        PropagatorConverter fitter = new FiniteDifferencePropagatorConverter(builder, 1.e-6, 5000);

        // Resulting propagator
        KeplerianPropagator kepProp = (KeplerianPropagator) fitter.convert(numProp, 2 * period, 251);

        // Step handlers
        StatesHandler numStepHandler = new StatesHandler();
        StatesHandler kepStepHandler = new StatesHandler();

        // Set up operating mode for the propagator as master mode
        // with fixed step and specialized step handler
        numProp.setMasterMode(60., numStepHandler);
        kepProp.setMasterMode(60., kepStepHandler);

        // Extrapolate from the initial to the final date
        numProp.propagate(initialDate.shiftedBy(10. * period));
        kepProp.propagate(initialDate.shiftedBy(10. * period));

        // retrieve the states
        List<SpacecraftState> numStates = numStepHandler.getStates();
        List<SpacecraftState> kepStates = kepStepHandler.getStates();

        // Print the results on the output file
        File output = new File(new File(System.getProperty("user.home")), "elements.dat");
        PrintStream stream = new PrintStream(output);
        stream.println("# date Anum Akep Enum Ekep Inum Ikep LMnum LMkep");
        for (SpacecraftState numState : numStates) {
            for (SpacecraftState kepState : kepStates) {
                if (numState.getDate().compareTo(kepState.getDate()) == 0) {
                    stream.println(numState.getDate() + " " + numState.getA() + " " + kepState.getA() + " "
                            + numState.getE() + " " + kepState.getE() + " "
                            + FastMath.toDegrees(numState.getI()) + " " + FastMath.toDegrees(kepState.getI())
                            + " " + FastMath.toDegrees(MathUtils.normalizeAngle(numState.getLM(), FastMath.PI))
                            + " "
                            + FastMath.toDegrees(MathUtils.normalizeAngle(kepState.getLM(), FastMath.PI)));
                    break;
                }
            }
        }
        stream.close();
        System.out.println("Results saved as file " + output);

        File output1 = new File(new File(System.getProperty("user.home")), "elts_pv.dat");
        PrintStream stream1 = new PrintStream(output1);
        stream.println("# date pxn pyn pzn vxn vyn vzn pxk pyk pzk vxk vyk vzk");
        for (SpacecraftState numState : numStates) {
            for (SpacecraftState kepState : kepStates) {
                if (numState.getDate().compareTo(kepState.getDate()) == 0) {
                    final double pxn = numState.getPVCoordinates().getPosition().getX();
                    final double pyn = numState.getPVCoordinates().getPosition().getY();
                    final double pzn = numState.getPVCoordinates().getPosition().getZ();
                    final double vxn = numState.getPVCoordinates().getVelocity().getX();
                    final double vyn = numState.getPVCoordinates().getVelocity().getY();
                    final double vzn = numState.getPVCoordinates().getVelocity().getZ();
                    final double pxk = kepState.getPVCoordinates().getPosition().getX();
                    final double pyk = kepState.getPVCoordinates().getPosition().getY();
                    final double pzk = kepState.getPVCoordinates().getPosition().getZ();
                    final double vxk = kepState.getPVCoordinates().getVelocity().getX();
                    final double vyk = kepState.getPVCoordinates().getVelocity().getY();
                    final double vzk = kepState.getPVCoordinates().getVelocity().getZ();
                    stream1.println(numState.getDate() + " " + pxn + " " + pyn + " " + pzn + " " + vxn + " "
                            + vyn + " " + vzn + " " + pxk + " " + pyk + " " + pzk + " " + vxk + " " + vyk + " "
                            + vzk);
                    break;
                }
            }
        }
        stream1.close();
        System.out.println("Results saved as file " + output1);

    } catch (OrekitException oe) {
        System.err.println(oe.getLocalizedMessage());
        System.exit(1);
    } catch (FileNotFoundException fnfe) {
        System.err.println(fnfe.getLocalizedMessage());
        System.exit(1);
    }
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    ServerSocket ss = new ServerSocket(80);
    while (true) {
        Socket s = ss.accept();/*  ww  w .j  av  a 2 s  .co  m*/
        PrintStream out = new PrintStream(s.getOutputStream());
        BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
        String info = null;
        while ((info = in.readLine()) != null) {
            System.out.println("now got " + info);
            if (info.equals(""))
                break;
        }
        out.println("HTTP/1.0 200 OK");
        out.println("MIME_version:1.0");
        out.println("Content_Type:text/html");
        String c = "<html> <head></head><body> <h1> hi</h1></Body></html>";
        out.println("Content_Length:" + c.length());
        out.println("");
        out.println(c);
        out.close();
        s.close();
        in.close();
    }
}

From source file:cc.twittertools.util.ExtractSubcollection.java

@SuppressWarnings("static-access")
public static void main(String[] args) throws Exception {
    Options options = new Options();

    options.addOption(OptionBuilder.withArgName("dir").hasArg().withDescription("source collection directory")
            .create(COLLECTION_OPTION));
    options.addOption(//from www. j  a v  a  2 s.c  o  m
            OptionBuilder.withArgName("file").hasArg().withDescription("list of tweetids").create(ID_OPTION));

    CommandLine cmdline = null;
    CommandLineParser parser = new GnuParser();
    try {
        cmdline = parser.parse(options, args);
    } catch (ParseException exp) {
        System.err.println("Error parsing command line: " + exp.getMessage());
        System.exit(-1);
    }

    if (!cmdline.hasOption(COLLECTION_OPTION) || !cmdline.hasOption(ID_OPTION)) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(ExtractSubcollection.class.getName(), options);
        System.exit(-1);
    }

    String collectionPath = cmdline.getOptionValue(COLLECTION_OPTION);

    LongOpenHashSet tweetids = new LongOpenHashSet();
    File tweetidsFile = new File(cmdline.getOptionValue(ID_OPTION));
    if (!tweetidsFile.exists()) {
        System.err.println("Error: " + tweetidsFile + " does not exist!");
        System.exit(-1);
    }
    LOG.info("Reading tweetids from " + tweetidsFile);

    FileInputStream fin = new FileInputStream(tweetidsFile);
    BufferedReader br = new BufferedReader(new InputStreamReader(fin));

    String s;
    while ((s = br.readLine()) != null) {
        tweetids.add(Long.parseLong(s));
    }
    br.close();
    fin.close();
    LOG.info("Read " + tweetids.size() + " tweetids.");

    File file = new File(collectionPath);
    if (!file.exists()) {
        System.err.println("Error: " + file + " does not exist!");
        System.exit(-1);
    }

    PrintStream out = new PrintStream(System.out, true, "UTF-8");
    StatusStream stream = new JsonStatusCorpusReader(file);
    Status status;
    while ((status = stream.next()) != null) {
        if (tweetids.contains(status.getId())) {
            out.println(status.getJsonObject().toString());
        }
    }
    stream.close();
    out.close();
}

From source file:at.tuwien.ifs.somtoolbox.apps.helper.VectorFileLabelLister.java

public static void main(String[] args) throws IOException {
    // register and parse all options
    JSAPResult config = OptionFactory.parseResults(args, OPTIONS);

    String inputVectorFileName = AbstractOptionFactory.getFilePath(config, "input");
    String outputFileName = AbstractOptionFactory.getFilePath(config, "output");

    PrintStream out;
    if (StringUtils.isBlank(outputFileName)) {
        out = System.out;/*from ww w  .j  av a  2  s .c  o  m*/
    } else {
        out = new PrintStream(outputFileName);
    }

    InputData data = InputDataFactory.open(inputVectorFileName);
    String[] labels = data.getLabels();
    Arrays.sort(labels);
    for (String s : labels) {
        out.println(s);
    }
    out.close();
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
    SSLServerSocket ss = (SSLServerSocket) ssf.createServerSocket(443);
    ss.setNeedClientAuth(true);/*  w  ww.ja va  2  s.  c o  m*/
    while (true) {
        Socket s = ss.accept();

        SSLSession session = ((SSLSocket) s).getSession();
        Certificate[] cchain = session.getPeerCertificates();
        for (int j = 0; j < cchain.length; j++) {
            System.out.println(((X509Certificate) cchain[j]).getSubjectDN());
        }
        PrintStream out = new PrintStream(s.getOutputStream());
        BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
        String info = null;
        while ((info = in.readLine()) != null) {
            System.out.println("now got " + info);
            if (info.equals(""))
                break;
        }

        out.println("HTTP/1.0 200 OK\nMIME_version:1.0");
        out.println("Content_Type:text/html");
        String c = "<html> <head></head><body> <h1> Hi,</h1></Body></html>";
        out.println("Content_Length:" + c.length());
        out.println("");
        out.println(c);
        out.close();
        s.close();
        in.close();
    }
}

From source file:hk.hku.cecid.corvus.http.AS2EnvelopQuerySender.java

/**
 * The main method is for CLI mode.//from   w  w  w  . j a  va  2 s . com
 */
public static void main(String[] args) {
    try {
        java.io.PrintStream out = System.out;

        if (args.length < 2) {
            out.println("Usage: as2-envelop [config-xml] [log-path]");
            out.println();
            out.println("Example: as2-envelop ./config/as2-envelop/as2-request.xml ./logs/as2-envelop.log");
            System.exit(1);
        }

        out.println("------------------------------------------------------");
        out.println("       AS2 Envelop Queryer       ");
        out.println("------------------------------------------------------");

        // Initialize the logger.
        out.println("Initialize logger .. ");
        // The logger path is specified at the last argument.
        FileLogger logger = new FileLogger(new File(args[args.length - 1]));

        // Initialize the query parameter.
        out.println("Importing AS2 administrative sending parameters ... ");
        AS2AdminData acd = DataFactory.getInstance()
                .createAS2AdminDataFromXML(new PropertyTree(new File(args[0]).toURI().toURL()));

        boolean historyQueryNeeded = false;
        AS2MessageHistoryRequestData queryData = new AS2MessageHistoryRequestData();
        if (acd.getMessageIdCriteria() == null || acd.getMessageIdCriteria().trim().equals("")) {

            historyQueryNeeded = true;

            // print command prompt
            out.println("No messageID was specified!");
            out.println("Start querying message repositry ...");

            String endpoint = acd.getEnvelopQueryEndpoint();
            String host = endpoint.substring(0, endpoint.indexOf("/corvus"));
            host += "/corvus/httpd/as2/msg_history";
            queryData.setEndPoint(host);
        } /*
            If the user has entered message id but no messagebox, 
            using the messageid as serach criteria and as 
            user to chose his target message
          */
        else if (acd.getMessageBoxCriteria() == null || acd.getMessageBoxCriteria().trim().equals("")) {

            historyQueryNeeded = true;

            // print command prompt
            out.println("Message Box value haven't specified.");
            out.println("Start query message whcih matched with messageID: " + acd.getMessageIdCriteria());

            String endpoint = acd.getEnvelopQueryEndpoint();
            String host = endpoint.substring(0, endpoint.indexOf("/corvus"));
            host += "/corvus/httpd/as2/msg_history";

            queryData.setEndPoint(host);
            queryData.setMessageId(acd.getMessageIdCriteria());
        }
        //Debug Message
        System.out.println("history Endpoint: " + queryData.getEndPoint());
        System.out.println("Repositry Endpoint: " + acd.getEnvelopQueryEndpoint());

        if (historyQueryNeeded) {
            List msgList = listAvailableMessage(queryData, logger);

            if (msgList == null || msgList.size() == 0) {
                out.println();
                out.println();
                out.println("No stream data found in repositry...");
                out.println("Please view log for details .. ");
                return;
            }

            int selection = promptForSelection(msgList);

            if (selection == -1) {
                return;
            }

            String messageID = (String) ((List) msgList.get(selection)).get(0);
            String messageBox = (String) ((List) msgList.get(selection)).get(1);
            acd.setMessageIdCriteria(messageID);
            acd.setMessageBoxCriteria(messageBox.toUpperCase());
            out.println();
            out.println();
            out.println("Start download targeted message envelop ...");
        }

        // Initialize the sender.
        out.println("Initialize AS2 HTTP data service client... ");
        AS2EnvelopQuerySender sender = new AS2EnvelopQuerySender(logger, acd);

        out.println("Sending    AS2 HTTP Envelop Query request ... ");
        sender.run();

        out.println();
        out.println("                    Sending Done:                   ");
        out.println("----------------------------------------------------");
        out.println("The Message Envelope : ");
        InputStream eins = sender.getEnvelopStream();
        if (eins.available() == 0) {
            out.println("No stream data found.");
            out.println("The message envelop does not exist for message id " + sender.getMessageIdToDownload()
                    + " and message box " + sender.getMessageBoxToDownload());
        } else
            IOHandler.pipe(sender.getEnvelopStream(), out);

        out.println("Please view log for details .. ");
    } catch (Exception e) {
        e.printStackTrace(System.err);
    }
}

From source file:Redirect.java

public static void main(String args[]) throws Exception {
    PrintStream origOut = System.out;
    PrintStream origErr = System.err;

    InputStream stdin = null;/*from   w ww  . j a  v a2  s . c o  m*/
    stdin = new FileInputStream("Redirect.in");
    PrintStream stdout = null;
    stdout = new PrintStream(new FileOutputStream("Redirect.out"));
    PrintStream stderr = null;
    stderr = new PrintStream(new FileOutputStream("Redirect.err"));
    origOut.println("1");
    System.out.println("2");
    origOut.println("3");
    System.err.println("4");
    origErr.println("5");

    System.setIn(stdin);
    System.setOut(stdout);
    System.setErr(stderr);

    origOut.println("\nR");
    System.out.println("T");
    origOut.println("Tq");
    System.err.println("Tqw");
    origErr.println("Test");

    origOut.println("\nRedirect:  Round #3");
    int inChar = 0;
    while (-1 != inChar) {
        try {
            inChar = System.in.read();
        } catch (Exception e) {
            // Clean up the output and bail.
            origOut.print("\n");
            break;
        }
        origOut.write(inChar);
    }

    stdin.close();
    stdout.close();
    stderr.close();

    System.exit(0);
}