This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 255964 - System.out.print and System.out.print are not working when working on netbeans 8.0.2
Summary: System.out.print and System.out.print are not working when working on netbea...
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 8.0.2
Hardware: PC Windows 10
: P3 normal (vote)
Assignee: Martin Balin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-16 03:41 UTC by gbnreddy
Modified: 2015-10-16 11:07 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gbnreddy 2015-10-16 03:41:25 UTC
****************************************************************************
import java.io.IOException;
public class Stp {
    public static void main(String args[]) throws IOException{
         System.out.println("++++++++++++++++++++++++++");
         System.out.println("+          TIMER         +");
         System.out.println("++++++++++++++++++++++++++");
		 System.out.print("+            ");
        for(int m=0;m<1;m++){
             for(int s=0;s<60;s++){
                  for(int ms=0;ms<10;ms++){
               try{
				   
                System.out.printf("%d:%d:%d\b\b\b\b\b\b\b",m,s,ms);
                Thread.sleep(100L);
               }catch(Exception e){
                System.out.println("error");
            }
           
           }
        }
      }
    }
}

***************************************************************************
when i run the above code it is not displaying the printf till program running ends
Comment 1 Martin Balin 2015-10-16 07:54:30 UTC
If e.g. "System.out.println("m="+ m + ", s=" + s + ", ms=" + ms);" is used under System.out.printf then it is always printed to output. Seems like an issue with java Formatter
Comment 2 Tomas Zezula 2015-10-16 08:35:51 UTC
The problem is that the output window is not a console, the System.out is a PrintStream (buffered) with autoFlush==true so it's flushed by:

The output is flushed either by:
1) By call of println
2) By '\n' char
3) byte[]

The 3) causes that it works fine on console but it's not flushed in output window, it requires '\n' or close.
Comment 3 gbnreddy 2015-10-16 10:15:04 UTC
When i tried the code  it worked for first time later its not printing .
Comment 4 gbnreddy 2015-10-16 11:04:13 UTC
Thank u Martin Balin that worked but i want to clear the console at each iteration of loop
Comment 5 gbnreddy 2015-10-16 11:07:43 UTC
(In reply to Tomas Zezula from comment #2)
> The problem is that the output window is not a console, the System.out is a
> PrintStream (buffered) with autoFlush==true so it's flushed by:
> 
> The output is flushed either by:
> 1) By call of println
> 2) By '\n' char
> 3) byte[]
> 
> The 3) causes that it works fine on console but it's not flushed in output
> window, it requires '\n' or close.

Thank u Tomas Zezula \n worked but my requirement is \b .
\n worked perfectly with printf
\b is not working 

Please suggest me something to fix this \b not working issue