3 Replies Latest reply: Jan 2, 2008 5:17 PM by 807603 RSS

    usage of print(String s)

    807603
      i am trying to write some different strings from different sources.. such as lets say i wanna write the path of my object say it is an abstract file object.. and then i wanna user to enter a command just in the same line so i use print() isntead of println() and then wait a command from user .. now untill i call println() it does not write the strings i wanted to be written to the console.. to make the console write whatver i try to write with print() as soon as i call print what should i do after a statement like System.out.print(str) ; ?
        • 1. Re: usage of print(String s)
          807603
          System.out.print(str);
          System.out.flush();
          • 2. Re: usage of print(String s)
            807603
            i am using netbeans IDe for java programming but i added the flush() method call but it still waits for println to be called to write all the buffer.. is taht a problem of IDE or java?


            i do not know certainly but if it may cause this error.. i use a scanner object and use its nextLine methd for user inputs..

            so how can i write without being have to wait println() call?

            Edited by: ishakteyran on Jan 2, 2008 3:13 PM
            • 3. Re: usage of print(String s)
              807603
              ishakteyran wrote:
              i am using netbeans IDe for java programming but i added the flush() method call but it still waits for println to be called to write all the buffer.. is taht a problem of IDE or java?


              i do not know certainly but if it may cause this error.. i use a scanner object and use its nextLine methd for user inputs..

              so how can i write without being have to wait println() call?

              Edited by: ishakteyran on Jan 2, 2008 3:13 PM
              Most probably a quirk of the "console" view in your IDE, which isn't a console at all, and can't really be relied on to behave properly as you're expecting. Wouldn't worry about "fixing" it, though, you're not deploying to your IDE after all!