1 jls.loader.provide('jls.io.PrintStream');
  2 
  3 jls.loader.require('jls.io.File');
  4 jls.loader.require('jls.io.OutputStreamWriter');
  5 jls.loader.require('jls.io.FileChannel');
  6 jls.loader.require('jls.io.FileOutputStream');
  7 
  8 jls.io.PrintStream = jls.lang.Class.create(jls.io.OutputStreamWriter, /** @lends jls.io.PrintStream.prototype */
  9 {
 10     /**
 11      * Creates a print stream.
 12      * 
 13      * @param {jls.io.OutputStream} out The underlying byte output stream or a file, a filename.
 14      * @param {String} csn The name of the character set to use.
 15      * @constructs
 16      * @augments jls.io.OutputStreamWriter
 17      * @class A print stream.
 18      */
 19     initialize : function($super, out, csn) {
 20         if ((out instanceof jls.io.FileChannel) || (out instanceof jls.io.FileOutputStream)) {
 21             // nothing to do
 22         } else if ((out instanceof jls.io.File) || (typeof out == 'string')) {
 23             out = new jls.io.FileOutputStream(out);
 24         } else if ((out instanceof _native.io.FileDesc) || (out instanceof _native.io.StaticFileDesc)) {
 25             out = new jls.io.FileChannel(out);
 26         } else {
 27             throw new jls.lang.Exception('Invalid outputstream');
 28         }
 29         $super(out, csn);
 30     },
 31     /**
 32      * Prints a string.
 33      *
 34      * @param {String} s The string to write.
 35      * @returns {Number} the write byte count.
 36      */
 37     print : function(s) {
 38         return this.write(s);
 39     },
 40     /**
 41      * Prints a string.
 42      *
 43      * @param {String} s The string to write.
 44      * @returns {Number} the write byte count.
 45      */
 46     println : function(s) {
 47         return this.writeLine(s);
 48     }
 49 });
 50