1 import java.io.*;
2
7 public class Tulostustesti {
8
9 private static void tulosta(OutputStream os,int h, int m) {
10 PrintStream out = new PrintStream(os);
11 out.println("" + h + ":" + m);
12 }
13
14 public static void main(String[] args) throws FileNotFoundException, IOException {
15 int h=12, m=15;
16
17 tulosta(System.out,h,m);
19
20 FileOutputStream f = new FileOutputStream("Tulostustesti.txt");
22 try {
23 tulosta(f,h,m);
24 } finally {
25 f.close();
26 }
27
28 ByteArrayOutputStream bs = new ByteArrayOutputStream();
30 tulosta(bs,h,m);
31 String s = bs.toString();
32 System.out.println(s); }
34
35 }
36