我正在实现一个命令行 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);
}