1 /**
2  * Authors: Frank Benoit <keinfarbton@googlemail.com>
3  */
4 module java.io.FileOutputStream;
5 
6 public import java.io.File;
7 public import java.io.OutputStream;
8 
9 import java.lang.all;
10 
11 version(Tango){
12     import TangoFile = tango.io.device.File;
13 } else { // Phobos
14     static import std.stdio;
15 }
16 
17 public class FileOutputStream : java.io.OutputStream.OutputStream {
18 
19     alias java.io.OutputStream.OutputStream.write write;
20     alias java.io.OutputStream.OutputStream.close close;
21     version(Tango){
22         private TangoFile.File fc;
23     } else { // Phobos
24         private std.stdio.File fc;
25     }
26 
27     public this ( String name ){
28         version(Tango){
29             fc = new TangoFile.File( name, TangoFile.File.WriteCreate );
30         } else { // Phobos
31             fc = std.stdio.File( name, "wb" );
32         }
33     }
34 
35     public this ( String name, bool append ){
36         version(Tango){
37             fc = new TangoFile.File( name, append ? TangoFile.File.WriteAppending : TangoFile.File.WriteCreate );
38         } else { // Phobos
39             fc = std.stdio.File( name, append ? "ab" : "wb" );
40         }
41     }
42 
43     public this ( java.io.File.File file ){
44         this( file.toString );
45     }
46 
47     public this ( java.io.File.File file, bool append ){
48         this( file.toString, append );
49     }
50 
51     public override void write( int b ){
52         ubyte[1] a = b & 0xFF;
53         version(Tango){
54             fc.write(a);
55         } else { // Phobos
56             fc.rawWrite(a);
57         }
58     }
59 
60     public override void close(){
61         fc.close();
62     }
63 
64     public void finalize(){
65         implMissing( __FILE__, __LINE__ );
66     }
67 
68 
69 }
70 
71