0
可能重复:
How to delete stuff printed to console by System.out.println()?清除控制台的Java
我有一个序列化词与词计数的链表一类泡菜。一切正常,除了控制台在我保存和加载数据时没有清除。即使当我离开eclipse并再次运行程序时,旧的控制台输出以及新的输出也会出现。无论如何要在加载对象数据之前清除控制台?这里是我的保存方法:
void save(T obj){
try{
FileOutputStream fos = new FileOutputStream(filename);
ObjectOutputStream out = new ObjectOutputStream(fos);
out.writeObject(obj);
out.close();
}catch(Exception e){
System.err.println(e);
System.exit(1);
}
}
和我的加载方法:
T load(){
try{
FileInputStream fis = new FileInputStream(filename);
ObjectInputStream in = new ObjectInputStream(fis);
temp = (T) in.readObject();
return temp;
}catch(FileNotFoundException f){
System.err.println("Warning! File Not Found. Null is returned");
System.exit(1);
return null;
} catch (Exception e) {
System.err.println(e);
System.exit(1);
return null;
}
}
什么控制台?你的意思是错误流? –
我应该说标准输出(System.out) – nh0815