Redirecting process output to jtextarea

I'd like to redirect the output of a process to a JTextArea that is continuously updated as the output comes in. Can anyone help me with this?

I'm basically confused as to how to do this.
I have the following class that I obtained from a site.
There's an example posted as to how to redirect system error ouput to a JTextArea using the Stream class below. I want to take the ouput of a launched process, and send it to a textarea.
import java.io.IOException;
import java.io.OutputStream;
import javax.swing.JTextArea;
public class TextAreaOutputStream extends OutputStream{
       private JTextArea textArea;
       private StringBuffer buff;
       public TextAreaOutputStream(JTextArea textArea){
         this.textArea = textArea;
         this.buff = new StringBuffer();     
       public void write(int b)throws IOException{
         // this next line is kind of a hatchet job... it works... but still
         buff.append(Character.toString((char)b));
         if(buff.length()>100){
           flush();     
       public void flush()throws IOException{
         this.textArea.append(buff.toString());
         this.buff = new StringBuffer();
       public void close()throws IOException{
         this.textArea = null;
         this.buff = null;
     }So I'd like to launch my process, and direct all output from that process to a Jtextarea? Is there a rough overview anyone can give me as to how this can be done?

Similar Messages

  • Redirecting cmd output to a JTextArea

    can anyone help me, im curious how can the compilers for java e.g.: Netbeans, JCreator, redirect the command promt output to a JTextArea..
    can anyone guide me on what class to look at??
    thanks a lot

    here is a simple class that redirects the standard output to a file called a.txt. you have to look into the class java.class.System. and other i/o classes
    import java.io.PrintStream;
    public class A {
        public A() {
        public static void main(String[] args) throws Exception {
            PrintStream fileOut = new PrintStream("a.txt");
            System.setOut(fileOut);
            for (int i = 0; i < 10; i++) {
                System.out.println(i);
    }for your case where output goes to a textArea you might wanna use a multithreaded solution. redirect your output to a file as above and use the thread to read the file and paste text into your text area. there is other better solution that directly passes data into the textArea. i'll post it if can find it in my code base.

  • How to redirect standard output/error of a ucb function to matrixx command window

    Is there a way to redirect standard output/error of a ucb function to matrixx command window?
    I know that the recommended way is to use stdwrt or XmathDisplay commands. However, we have some
    libraries that already exists which uses printf calls and I would like to redirect their output
    to the matrixx command window.
    Thanks

    Hi,
    What you need to do is create a printf function that will print the information into a string, then you can use stdwrt to display it in Xmath.
    Then you tell the UCB linking process to compile and link with this version of printf.c
    I am including the printf.c that we used to test the function you needed.
    Hope this helps.
    Attachments:
    printf.c ‏1 KB

  • Runing an exec from class Runtime and redirecting its output ...?..?

    Hello!
    I am trying to run a C exec by using th eRuntime class.
    This works well ...
    But, I want to redirect its output to my transcript.
    This also works with small output (some lines !) ...
    But the out put is up to 3000 lines, my program does
    not continue. It is suspended in a waiting state.
    I suspected that the buffer is filled, but there is still some lines to be written ...?
    Anyone knows this problem and the solution ..?
    Thanks by advance
    Yaz

    You could try something like thisjava.util.List al = new ArrayList();
    try {
         Process p = Runtime.getRuntime().exec("cmd.exe /c dir");
         BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
         String s = "";
         while ((s=br.readLine()) != null) {
              al.add(s);
         ListIterator li = al.listIterator();
         while (li.hasNext()) {
              System.out.println(li.next());
    catch (IOException ioe) {}Mark

  • How to redirect the output display on Ultra 5 box.

    Hello,
    Good day to you.
    I have issues with redirecting display output to my console server (which is configured with cyclades switch) on a newly installed solaris 10, Ultra 5 box.
    I could access the output display on the monitor when I connect it directly to the serial port. But I also have my parallel port connected to cyclades switch which is primarily being used for accessing multiple servers thro' one single console server.
    When I try to access my ultra 5 box thro' console server, the display not getting redirected over there..I did checked the port from cyclades switch front, it did work well with other machines.
    Looks like some work needs to be done at Ultra 5 box level so that the parallel port can send output signals to the respective port on cyclades switch and consequently to the console server.
    Any thoughts ??
    Thanks.

    Hi,
    Good day to you.
    Apologize for quoting "Parallel" port. It is a in-built 25pin serial connector placed next to regular 15 pin serial port.
    Just to make a point here, this 25 pin serial connector has an external converter attached with other side having RJ45 jack.
    CAT5 cable connected between switch port to this RJ45 jack.
    I did tested this converter with another machine and could able to access the display on my console server. So it seems to be the connectivity from serial port to switch port works fine.
    Adding to that, this ultra 5 box with the current connectivity set up was working fine until I rebuild this machine. I was very well accessing this box thro my console server. There was no changes done except rebuilding the operating system.
    I think some work needs to be done at the ultra 5 box level to get this 25pin serial connector to act.
    Thanks.

  • Our organization uses an Oracle database hosted on a Unix platform and one of our data processing outputs is a "stuffer" document that has a barcode, and Unix jobs automatically send the document to a printer.   Is there a way, or does Adobe have a produc

    Our organization uses an Oracle database hosted on a Unix platform and one of our data processing outputs is a “stuffer” document that has a barcode, and Unix jobs automatically send the document to a printer.
    Is there a way, or does Adobe have a product or solution, to create a PDF version of the document including the barcode, before it’s sent to a printer?

    What format is the document that is printed? Or what technology is used to format the printer? There isn't a standard way of doing things in Unix.

  • Redirect standart output to file

    i want to ask how to redirect standart output to file,
    if i have statement like this System.out.println("hello"); i want hello not print in console but print to file
    thx

    Here is sample code for that:
      static{
        try {
          PrintStream obj_ps = new PrintStream(new FileOutputStream("internal.log"));
          System.setOut(obj_ps);
          System.setErr(obj_ps);
        catch (FileNotFoundException ex) {
          JOptionPane.showMessageDialog(null, "Error creating log file", "Error", JOptionPane.ERROR_MESSAGE);
      }

  • How to redirect CELLCLI output to text file

    Hi,
    I would like to redicrect the output of the cellcli command to a text file .
    For example , how to redirect the output of this command to a text file on /tmp
    CellCLI> list metrichistory where objectType = 'CELL' -
    and name = 'CL_TEMP'Thanks

    cellcli has spooling capabilities similar to sqlplus:
    CellCLI> help spool
      Usage:  SPO[OL] [<filename> [ CRE[ATE] | REP[LACE] | APP[END]] | OFF ]
      Purpose: SPOOL <filename>: Direct the results to the file <filename>.
               SPOOL OFF: Turn off the spooling.
               SPOOL: Check the current spooling status.
      Arguments:
        <filename>: The filename where the results will be output.
      Options:
        [APPEND]: If the filename already exists, the following output will
                  be appended to the file. Without this option, the existing file
                  contents will be replaced.
        [CREATE]: If the filename already exists, an error is reported.
        [REPLACE]: If the filename already exists, the contents will be
                  replaced.  This is the default, when no option is provided.
      Examples:
        spool myfile
        spool myfile append
        spool off
        spoolBut if you are trying to script it, it would be easier to just run it command line:
    # cellcli -e "list metrichistory where objectType = 'CELL' and name = 'CL_TEMP'" > /tmp/CL_TEMP.txtAlso look into dcli which allows you to run cellcli commands on one or more cells from a compute node.
    Good luck.

  • Redirecting XSLT output to multiple files

    Hi,
    I am trying to redirect the output of the XSLT into multiple files using
    <xsl:variable name="filename" select="concat(@id,'.xml')" />
    <redirect:write select="$filename">
    </redirect:write>I dont want to hard-code the directory of the $filename in XSL, I want to set it or resolve it programatically in the java code.
    Can you please tell me if this can be done in someway ?

    Aravinda wrote:
    I dont want to hard-code the directory of the $filename in XSL, I want to set it or resolve it programatically in the java code.
    Can you please tell me if this can be done in someway ?You + setParameter + method of your Transformer in java code to set parameters. like below:
    transformer.setParameter("message1", "This is my message to XSLT from Java Class.");
    transformer.setParameter("message2", "Hello XSLT how are you?");
    . . .You can retrieve above parameters in global parameters/variables(must be as child of xsl:stylesheet element in xslt) defined in xslt like below:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
         <xsl:param name="message1"></xsl:param>
         <xsl:variable name="message2"></xsl:variable>
         <xsl:template match="/">
              <xsl:value-of select="$message1"/>     // retrieving message1
              <xsl:value-of select="$message2"/>     // retrieving message2
              <xsl:value-of select="concat($message1,$message2)"/>     // performing concat on message1 and message2
         </xsl:template>
    </xsl:stylesheet>*Cheers
    TYPUROHIT*
    (Tejas Purohit)

  • How to redirect console output while starting server from within IDE

    Hello, i am using Weblogic Workshop IDE. When I start the server, a new cmd shell is launched and the jvm output is displayed in this cmd shell window. How can I redirect this output to show up within the IDE (for instance in the Console view)?
    Problem is that when an error occurs, the cmd window disappears and I cannot tell what the error was.
    Surely there is a way to do this as other IDEs (JBuilder, Rational etc.) allow this.
    Thanks:
    -Sam

    Hi Sam,
    Unfortunately, this feature does not exist in Workshop 9.2
    Regarding your question about redirecting the output, the logs are saved under the domain directory.
    You could also refer to the following section for additional info on redirecting the output to multiple destinations.
    http://e-docs.bea.com/wls/docs90/ConsoleHelp/taskhelp/logging/RedirectJVMOutput.html
    Hope this helps.
    cheers
    Raj

  • Redirect the output of SQL*Plus to the file

    Hi all,
    I have the following command to run:
    sqlplus username/password @myfile.sql
    I don't know how to redirect the output to the file.
    Also in the script myfile.sql I have the defined variable, &VP and
    How can I substitute this variable(&VP) at the run time.
    Thanks,
    JP

    Assumed you like to replace your defined variable VP by number 4. SInce it is posintional parameter,instead of wrinting &VP, write
    VP:=&1
    sqlplus>spool redirect.txt
    sqlplus>@myfile.sql 4
    sqlplus>spool off

  • IS IT POSSIBLE TO REDIRECT THE OUTPUT TO ANOTHER PAGE?

    Hi all,
    Is it possible to redirect the output when I excute my query in iSQL*plus to another predifined html page?
    If yes how do I do this?
    Thanks a mill

    You could do this..just read on..
    It would generate a html page for you...and..so on..!
    In addition to plain text output, the SQL*Plus command-line interface enables you to generate either a complete web page, or HTML output which can be embedded in a web page. You can use SQLPLUS -MARKUP "HTML ON" or SET MARKUP HTML ON SPOOL ON to produce complete HTML pages automatically encapsulated with <HTML> and <BODY> tags.
    By default, data retrieved with MARKUP HTML ON is output in HTML, though you can optionally direct output to the HTML <PRE> tag so that it displays in a web browser exactly as it appears in SQL*Plus. See the SQLPLUS MARKUP Options and the SET MARKUP command for more information about these commands.
    SQLPLUS -MARKUP "HTML ON" is useful when embedding SQL*Plus in program scripts. On starting, it outputs the HTML and BODY tags before executing any commands. All subsequent output is in HTML until SQL*Plus terminates.
    The -SILENT and -RESTRICT command-line options may be effectively used with -MARKUP to suppress the display of SQL*Plus prompt and banner information, and to restrict the use of some commands.
    SET MARKUP HTML ON SPOOL ON generates an HTML page for each subsequently spooled file. The HTML tags in a spool file are closed when SPOOL OFF is executed or SQL*Plus exits.
    You can use SET MARKUP HTML ON SPOOL OFF to generate HTML output suitable for embedding in an existing web page. HTML output generated this way has no <HTML> or <BODY> tags.

  • Possible to redirect JSP output?

    Is it possible to redirect the output of a JSP either directly to a printer or directly to a File object? I would like to write a report template using JSP and be able to display it via a browser (so far so good, that's what JSP does) but I'd also like to take the same output that the JSP generates and either print it directly (as in printing many many reports without having to run each one in a browser and click the browser print button) AND to be able to email the report to a client.
    Each of these means I need to redirect the output of a JSP. I couldn't find anything in this forum about that. Is this even possible?
    Thank you in advance for your answers.

    The problem with using a new URLConnection is that the current session is not applied to the JSP page as desired.
    For those using Tomcat 4, which implements the Servlet 2.3 spec, this page describes how to replace the output stream of a servlet with your own.
    http://www-106.ibm.com/developerworks/java/library/j-tomcat/
    The example implements a character replacement mechanism. Using a filter and a wrapper. I modified this example to redirect the output stream to a file, which allowed me to then e-mail the output of a JSP. I did this by only using the wrapper classes.
    Here are the relavant excerpts from my code
    //Inside the servlet:
    //{snip}...
    String sFileName = "e:\\temp\\email\\temp.html";
    RedirectTextWrapper rTW =
    new RedirectTextWrapper(response, sFileName);
    gotoPage(sAddress, request, rTW);
    //{snip}...
    //Supporting classes:
    class RedirectTextStream
    extends ServletOutputStream {
    private OutputStream intStream;
    private boolean closed = false;
    public RedirectTextStream(String sFileName) {
    try{
    intStream = new FileOutputStream(sFileName);
    }catch(FileNotFoundException e){
    e.printStackTrace();
    public void write(int i)
    throws java.io.IOException {
    intStream.write(i);
    public void close()
    throws java.io.IOException {
    if (!closed) {
    intStream.close();
    closed = true;
    public void flush() throws java.io.IOException {
    intStream.flush();
    class RedirectTextWrapper
    extends HttpServletResponseWrapper {
    private PrintWriter tpWriter;
    private RedirectTextStream tpStream;
    public RedirectTextWrapper(ServletResponse inResp,
    String sFileName)
    throws java.io.IOException {
    super((HttpServletResponse) inResp);
    tpStream = new RedirectTextStream(sFileName);
    tpWriter = new PrintWriter(tpStream);
    public ServletOutputStream getOutputStream()
    throws java.io.IOException {
    return tpStream;
    public PrintWriter getWriter()
    throws java.io.IOException {
    return tpWriter;
    }

  • Redirect process

    how to write redirect process in dynamic action when i click a button and at the same time page should not refresh.And should take me to that page num which i give

    Hi,
    You don't really need DA for that. A Button in Region Postion type, Action When Button Clicked > Action = Redirect to Page in this Application will do the job.
    Cheers,

  • Redirect SM50 output on unix file

    Hello,
    how can we execute daily SM50 daily and redirect html output on unix file?
    I Tried SE38, execute SM50 succefully, but no way to redirect output of this transaction on a unix file ?
    Thanks in advance.

    Hi majda,
    Hope you are doing good.
    Maybe check /nSM49 and create a OS command using ">>" operator Divyanshu mentioned:
    Restrict Authorizations for Executing External Commands - SAP NetWeaver Application Server ABAP Security Guide - SAP Lib…
    Thank you!
    Kind Regards,
    Hemanth
    SAP AGS

Maybe you are looking for