现在的结果:
2012年6月30日 15点19分3秒
2012年6月30日 15点19分4秒
2012年6月30日 15点19分5秒
2012年6月30日 15点19分6秒
2012年6月30日 15点19分7秒
2012年6月30日 15点19分8秒
想要的结果是:只有1行,然后时间不断刷新:2012年6月30日 15点19分3秒(时间在不断刷新)

解决方案 »

  1.   

    参考下:package csdn.calculate;
    import java.util.Date;
    public class OutALine
    {
    public static void main(String[] args)
    {
    Date date;
    for(int i=0;i<10000;i++)
    {
    date=new Date();
    String str=date.toString();
    System.out.print(str); //不换行.
    try
    {
    Thread.sleep(100);
    }
    catch(InterruptedException ie)
    {
    ie.printStackTrace();
    }
    int length=str.length();
    for(int j=0;j<length;j++)
    {
    System.out.print("\b"); //用退格清空.
    }
    }
    }
    }