【发布时间】:2012-12-15 08:18:35
【问题描述】:
我正在实现一个 mp3 播放器,它是命令行。
我想像这样显示 mp3 时长
Now Playing :: hello.mp3 Duration :: 1.20
但是当我使用 System.out.println 时它会显示
Now Playing :: hello.mp3 Duration :: 1.20
Now Playing :: hello.mp3 Duration :: 1.21
Now Playing :: hello.mp3 Duration :: 1.22
Now Playing :: hello.mp3 Duration :: 1.23
Now Playing :: hello.mp3 Duration :: 1.24
Now Playing :: hello.mp3 Duration :: 1.25
.....
基本上是由线程更新的持续时间,我想显示一行,我的意思是持续时间必须在单行中更新。我看到了Flushable interface,但没有得到它。请帮帮我
这是我的话题
while(p.getPlayer().isComplete() == false){
String bOutput = "\r Duration ::" + (int) ((p.getPlayer().getPosition() / (1000*60)) % 60) + " : " + (int) (p.getPlayer().getPosition() / 1000) % 60;
//p.getBufferedOutputStream().write(bOutput.getBytes());
//p.getBufferedOutputStream().flush();
System.out.println(bOutput);
Thread.sleep(1000);
}
【问题讨论】:
-
Here 建议如何覆盖现有的控制台行。这就是你所追求的吗?
-
刚刚看到编辑。尝试使用 System.out.print(bOutput) 而不是 System.out.println(bOutput)。
-
这个帖子会有所帮助 - stackoverflow.com/questions/1001335/…
标签: java io outputstream