Results 1 to 6 of 6

Thread: Redirecting standard output other than console

  1. #1
    Join Date
    Jul 2009
    Posts
    140

    Redirecting standard output other than console

    Hello,
    I wanted to know if it is possible to redirect a standard output stream (System.out) not to the console by default, but to any insertion point keyboard online? How to do it if possible or else it is that we can redirect to a field before a specific application? I already tried System.setOut (PrintStream) but I only found examples to send to a txt file. Thank you in advance for your answers.
    Last edited by Ameeryan; 08-01-2010 at 12:01 PM.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Redirecting standard output other than console

    Hi
    It should be possible to implement a PrintStream that stores received bytes into a buffer, waiting to be flush. When it is been flushed, it transforms the bytes into a String and uses SwingUtilities.invokeAndWait () to a text field day with this String. Hope this helps you. I would like to ask you, why do you want this when you have console with you, which can display most every thing, at-least for testing.

  3. #3
    Join Date
    Jul 2009
    Posts
    140

    Re: Redirecting standard output other than console

    Hi
    This method SwingUtilities.invokeAndWait () would allow me to display a string, a text field of an application that I developed. To be clearer, I try to redirect my System.out.println ( "my text") to the keyboard input of any application (notepad, word, textboxes of a webpage ...). As when using a bar code reader which displays the Live keyboard input. Do you have any more ideas about this, how I can do this?

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Redirecting standard output other than console

    Hi
    To send in an application, I do not see anything other than use robot and simulate key press: p
    Regarding the mechanism System.out ......
    You must first make a System.setOut (.....), and provide a PrintStream
    To build this PrintStream, here's an example from one of my projects:
    this.out = new PrintStream (new OutputStream ()
    {
    public void write (int charInt)
    {
    .
    .
    }
    ), True);
    You must implement "public void write (int charInt)"
    You retrieve your character by character System.out.println ()

  5. #5
    Join Date
    Jul 2009
    Posts
    140

    Re: Redirecting standard output other than console

    Hi
    Thank you for that, I do not know but it works with the method keyPress (int keycode). By cons I can not convert my string in character from the keyboard (int keycode).
    And I too do not understand how to use the PrintStream as you described above. Can you explain me with an example so it would be easy for me to understand.

  6. #6
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Redirecting standard output other than console

    Hi
    Robot will simulate keypresses on the keyboard. View Class KeyEvent for keycodes.
    For PrintStream: System.out is an object of type PrintStream. This object displays the text received by its methods "print" in the console. To retrieve the text that you want to display by making a System.out.println () must replace System.out. To do this, you use System.setOut (). This method has as argument a PrintStream, which will replace System.out. The PrintStream class is an OutputStream, but provided few facilities, such as "System.out.println ()". Therefore instantiate a new PrintStream order to use it. The constructor that will interest us is the following: "PrintStream(OutputStream out, boolean autoflush) ". So we must also instantiate an OutputStream.

Similar Threads

  1. Replies: 2
    Last Post: 28-10-2010, 01:56 PM
  2. Intel DH57JG, no HDMI output support in HD Audio Console
    By Potawatomi in forum Motherboard Processor & RAM
    Replies: 3
    Last Post: 09-10-2010, 02:53 AM
  3. URL Redirecting + Pop-Ups Virus
    By Surpassing in forum Networking & Security
    Replies: 4
    Last Post: 09-04-2010, 05:26 PM
  4. Redirecting the URL to another Web server
    By Luther in forum Technology & Internet
    Replies: 2
    Last Post: 24-10-2008, 06:03 PM
  5. Replies: 3
    Last Post: 03-09-2008, 01:39 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,144,435.02830 seconds with 16 queries