-1
我试图用一个PrintStream那字符串写入到另一个的OutputStream(在这种情况下下,System.out)指导Outputstreams到的System.out流
public void druckeDaten(OutputStream os){
String t = "ID = " + getID() + " \"" + getTitel() + "\" "
+ "von " + interpreter + " aus " + getJahr()
+ " Spieldauer: " + dauer + " sek.";
PrintStream pw = new PrintStream(os);
pw.printf(t);
pw.flush();
pw.close();
}
如果我调用该方法druckeDaten在循环,控制台只打印一行
Collections.sort(liste);
//liste is a LinkedList containing the Objects that I want to use the druckeDaten on
for(Medium m : liste)
m.druckeDaten(System.out);
我在哪里出错了?
您正在关闭您的方法druckeDaten中的流。 – Markus