Results 1 to 2 of 2
  1. #1
    JohnDoe is offline Member
    Join Date
    Sep 2010
    Posts
    1
    Rep Power
    0

    Default System.out.println

    Hey everyone,

    Is it possible to use ascii escape codes to colour the foreground or background of a console? I already tried:

    Java Code:
    System.out.println("\033[31m\033[44mHello world\033[0m\n");
    However without succes. Is there another possibility to achieve this?

    Kind regards

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,004
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by JohnDoe View Post
    Hey everyone,

    Is it possible to use ascii escape codes to colour the foreground or background of a console? I already tried:

    Java Code:
    System.out.println("\033[31m\033[44mHello world\033[0m\n");
    However without succes. Is there another possibility to achieve this?

    Kind regards
    Use the unicode escape sequence (\u<four hex digits>) instead:

    Java Code:
    System.out.println("\u001b[31m\u001b[44mHello world\u001b[0m\n");
    Beware that those escape codes are terminal dependent and may work on one terminal but not on another (also see the "jcurses" package).

    kind regards,

    Jos

Similar Threads

  1. Println VS system.out.println
    By ccie007 in forum New To Java
    Replies: 2
    Last Post: 05-20-2010, 08:52 AM
  2. difference between system.out.println() & out.println()
    By wickedrahul9 in forum Advanced Java
    Replies: 5
    Last Post: 10-18-2008, 11:06 PM
  3. System.out.println
    By Sniper-X in forum Advanced Java
    Replies: 10
    Last Post: 05-05-2008, 03:41 PM
  4. System.out.println
    By sunjavaboy in forum Advanced Java
    Replies: 3
    Last Post: 03-22-2008, 01:30 AM
  5. Help me with system.out.println
    By baltimore in forum New To Java
    Replies: 1
    Last Post: 07-31-2007, 08:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •