Package gov.lanl.util

Examples of gov.lanl.util.ExecuteStreamHandler


        try {
            final String command = getKduExtractCommand(input, output, dims, params);
            final Process process = Runtime.getRuntime().exec(command, envParams, new File(env));
            ByteArrayOutputStream stdout = new ByteArrayOutputStream();
            ByteArrayOutputStream stderr = new ByteArrayOutputStream();
            ExecuteStreamHandler streamHandler = new PumpStreamHandler(stdout, stderr, is);
            try {
                streamHandler.setProcessInputStream(process.getOutputStream());
                streamHandler.setProcessOutputStream(process.getInputStream());
                streamHandler.setProcessErrorStream(process.getErrorStream());
            } catch (IOException e) {
                logger.error(e, e);
                if (process != null) {
                    closeStreams(process);
                }
                throw e;
            }
            streamHandler.start();

            try {
                waitFor(process);
                final ByteArrayInputStream bais = new ByteArrayInputStream(stdout.toByteArray());
                bi = new PNMReader().open(bais);
                streamHandler.stop();
            } catch (ThreadDeath t) {
                logger.error(t, t);
                process.destroy();
                throw t;
            } finally {
View Full Code Here


            String command = getKduExtractCommand(input, output, dims, params);
            String[] cmdParts = CommandLineTokenizer.tokenize(command);
            Process process = Runtime.getRuntime().exec(cmdParts, envParams, new File(env));
            ByteArrayOutputStream stdout = new ByteArrayOutputStream();
            ByteArrayOutputStream stderr = new ByteArrayOutputStream();
            ExecuteStreamHandler streamHandler = new PumpStreamHandler(stdout, stderr, is);

            try {
                streamHandler.setProcessInputStream(process.getOutputStream());
                streamHandler.setProcessOutputStream(process.getInputStream());
                streamHandler.setProcessErrorStream(process.getErrorStream());
            } catch (IOException e) {
                LOGGER.error(e.getMessage(), e);

                if (process != null) {
                    closeStreams(process);
                }

                throw e;
            }

            streamHandler.start();

            try {
                waitFor(process);
                final ByteArrayInputStream bais = new ByteArrayInputStream(stdout.toByteArray());
                bi = new PNMReader().open(bais);
                streamHandler.stop();
            } catch (ThreadDeath t) {
                LOGGER.error(t.getMessage(), t);
                process.destroy();
                throw t;
            } finally {
View Full Code Here

TOP

Related Classes of gov.lanl.util.ExecuteStreamHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.