[投稿123] System.setOut 法
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.IOException;
class MyOutputStream extends PrintStream {
MyOutputStream(OutputStream out) {
super(out);
}
public void write(byte[] b, int off, int len)
{
// 這邊應該有更好的寫法,不過我先用比較笨的 :Q
byte[] new_b = new byte[b.length];
for (int i = off; i < len; i++)
if (b[i] < 10) // 避免轉換 \r\n
new_b[i] = (byte)(b[i] + 48);
else
new_b[i] = b[i];
super.write(new_b, off, len);
}
}
public class Output {
public static void main(String[] args) {
System.setOut(new MyOutputStream(System.out));
Output123.main(null);
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.251.145.119
推
09/28 13:23, , 1F
09/28 13:23, 1F
→
09/28 13:29, , 2F
09/28 13:29, 2F
推
10/03 04:07, , 3F
10/03 04:07, 3F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
java 近期熱門文章
PTT數位生活區 即時熱門文章