Print to console, or write to file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • twibblej
    New Member
    • Nov 2007
    • 3

    #1

    Print to console, or write to file

    Hello, I have a function which currently prints the contents of an object to the console. I want pass the function an arguement so that instead of always printing the object to the console it.

    a) prints contents of object to console
    or
    b) prints contents of object to file

    depending what input the print function is given.

    Now, I know I can just pass the function an open file to print to. What can I pass instead of an open file to make the function print to the console?

    THanks,
    Jonathan
  • twibblej
    New Member
    • Nov 2007
    • 3

    #2
    Sorry, I thought I was in a java forum so there would be no need... but to be clear this is Java that I am working with.

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by twibblej
      Sorry, I thought I was in a java forum so there would be no need... but to be clear this is Java that I am working with.
      Have a look at the System.setOut method.

      Comment

      • twibblej
        New Member
        • Nov 2007
        • 3

        #4
        thats what I needed. Thanks very much!

        Comment

        Working...