我試圖從文本文件中刪除0.0
的所有行。刪除文本文件中的某個元素的行
這就是它輸出:
0037823478362839 0.0
0236530128715607 3.88
0425603748320896 36.09
0659644925904600 13.58
0823485731970306 0.0
0836430488858603 46.959999999999994
這就是我希望它輸出
0236530128715607 3.88
0425603748320896 36.09
0659644925904600 13.58
0836430488858603 46.959999999999994
代碼:
// Collects the billing information and outputs them to a user defined .txt file
public void getBill() {
try {
PrintStream printStream = new PrintStream(outputFile);
Passenger[] p = getAllPassengers();
for(Passenger a : p){
printStream.print(a.getCardNumaber() + " ");
printStream.println(a.getBill());
}
printStream.close();
} catch(Exception e){
}
}
向我們展示'Passenger'的代碼,特別是'getBill()'的返回類型。 – 2013-10-31 10:47:51
對於初學者:它被稱爲Java,而不是JAVA,它不是首字母縮寫詞。 – Bobby
看來你只需要測試a.getBill()的值。如果它等於0,那麼你不打印相應的行。 – Julien