Results 1 to 6 of 6
  1. #1
    emailkia is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default How to modify System.out.println()

    Hi everyone,

    How can I change the System.out.println(x) to allways act as System.out.println(this + x)

    The reason is that I have a project with thousand of java-files and in every one of them there are several System.out.println(). I would like to know what java class is printing on the console. I thought maybe there is a way to modify the System.out.print/println in the main Java library so it would allways do as write the class name or some kind of clue about which class it is first and then the content of println ... But I don't know how?

    Can I modify System.out.println in Java??? Is this possible at all? //Thanks

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    You can find the java source files in the java folder on your computer, for a windows it should be located somewhere similar to
    Java Code:
    c:/program files/java/jdk/src
    It may be risky however to modify the java library.

  3. #3
    emailkia is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default

    Is it really possible to modify Java API source becase I thought it is not possible?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default

    Use a proper logging framework.
    It's a lot easier.

    Other than that you would have to write your own extension of PrintStream, overriding println() print() etc etc, and set System.out to an instance of that.

    But using a logging framework would be far more sensible.

  5. #5
    emailkia is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default Thanks

    Many thanks for you advices.

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,987
    Rep Power
    9

Similar Threads

  1. System.out.println
    By JohnDoe in forum New To Java
    Replies: 1
    Last Post: 09-05-2010, 10:14 AM
  2. System.out.println(040|343);
    By satheshshiva in forum New To Java
    Replies: 5
    Last Post: 06-26-2010, 10:26 PM
  3. Println VS system.out.println
    By ccie007 in forum New To Java
    Replies: 2
    Last Post: 05-20-2010, 08:52 AM
  4. difference between system.out.println() & out.println()
    By wickedrahul9 in forum Advanced Java
    Replies: 5
    Last Post: 10-18-2008, 11:06 PM
  5. System.out.println
    By sunjavaboy in forum Advanced Java
    Replies: 3
    Last Post: 03-22-2008, 01:30 AM

Posting Permissions

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