1 |
/* PrintStream.java -- OutputStream for printing output |
/* PrintStream.java -- OutputStream for printing output |
2 |
Copyright (C) 1998, 1999, 2001, 2003 Free Software Foundation, Inc. |
Copyright (C) 1998, 1999, 2001, 2003, 2005 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
56 |
* @author Aaron M. Renn <arenn@urbanophile.com> |
* @author Aaron M. Renn <arenn@urbanophile.com> |
57 |
* @author Tom Tromey <tromey@cygnus.com> |
* @author Tom Tromey <tromey@cygnus.com> |
58 |
*/ |
*/ |
59 |
public class PrintStream extends FilterOutputStream |
public class PrintStream extends FilterOutputStream implements Appendable |
60 |
{ |
{ |
61 |
/** |
/** |
62 |
* This boolean indicates whether or not an error has ever occurred |
* This boolean indicates whether or not an error has ever occurred |
136 |
this.auto_flush = auto_flush; |
this.auto_flush = auto_flush; |
137 |
} |
} |
138 |
|
|
139 |
|
/** @since 1.5 */ |
140 |
|
public PrintStream (String filename) throws FileNotFoundException |
141 |
|
{ |
142 |
|
super (new FileOutputStream (filename)); |
143 |
|
pw = new PrintWriter (new OutputStreamWriter (out), false); |
144 |
|
auto_flush = false; |
145 |
|
} |
146 |
|
|
147 |
|
/** @since 1.5 */ |
148 |
|
public PrintStream (String filename, String encoding) |
149 |
|
throws FileNotFoundException |
150 |
|
{ |
151 |
|
super (new FileOutputStream (filename)); |
152 |
|
pw = new PrintWriter (new OutputStreamWriter (out, encoding), false); |
153 |
|
auto_flush = false; |
154 |
|
} |
155 |
|
|
156 |
|
/** @since 1.5 */ |
157 |
|
public PrintStream (File file) throws FileNotFoundException |
158 |
|
{ |
159 |
|
super (new FileOutputStream (file)); |
160 |
|
pw = new PrintWriter (new OutputStreamWriter (out), false); |
161 |
|
auto_flush = false; |
162 |
|
} |
163 |
|
|
164 |
|
/** @since 1.5 */ |
165 |
|
public PrintStream (File file, String encoding) |
166 |
|
throws FileNotFoundException |
167 |
|
{ |
168 |
|
super (new FileOutputStream (file)); |
169 |
|
pw = new PrintWriter (new OutputStreamWriter (out, encoding), false); |
170 |
|
auto_flush = false; |
171 |
|
} |
172 |
|
|
173 |
/** |
/** |
174 |
* This method checks to see if an error has occurred on this stream. Note |
* This method checks to see if an error has occurred on this stream. Note |
175 |
* that once an error has occurred, this method will continue to report |
* that once an error has occurred, this method will continue to report |
501 |
setError (); |
setError (); |
502 |
} |
} |
503 |
} |
} |
504 |
|
|
505 |
|
/** @since 1.5 */ |
506 |
|
public PrintStream append(char c) throws IOException |
507 |
|
{ |
508 |
|
print(c); |
509 |
|
return this; |
510 |
|
} |
511 |
|
|
512 |
|
/** @since 1.5 */ |
513 |
|
public PrintStream append(CharSequence cs) throws IOException |
514 |
|
{ |
515 |
|
print(cs == null ? "null" : cs.toString()); |
516 |
|
return this; |
517 |
|
} |
518 |
|
|
519 |
|
/** @since 1.5 */ |
520 |
|
public PrintStream append(CharSequence cs, int start, int end) |
521 |
|
throws IOException |
522 |
|
{ |
523 |
|
print(cs == null ? "null" : cs.subSequence(start, end).toString()); |
524 |
|
return this; |
525 |
|
} |
526 |
} // class PrintStream |
} // class PrintStream |
527 |
|
|