public ZOutputStream(java.io.OutputStream outJ, int level, bool nowrap) : base()
 {
     this.outJ = outJ;
     z.deflateInit(level, nowrap);
     compress = true;
     buf      = new byte[bufsize];
 }
Example #2
0
        private void init(java.io.InputStream inStream, java.io.OutputStream outStream, int blockSize, int recordSize)
        {
            this.inStream  = inStream;
            this.outStream = outStream;

            this.initialize(blockSize, recordSize);
        }
Example #3
0
        /*
         * Utilities for Preferences export
         */
        internal static void exportPrefs(Preferences prefs, java.io.OutputStream stream,
                                         bool withSubTree)
        {        //throws IOException, BackingStoreException {
            indent = -1;
            java.io.BufferedWriter outJ = new java.io.BufferedWriter(new java.io.OutputStreamWriter(stream,
                                                                                                    "UTF-8"));
            outJ.write(HEADER);
            outJ.newLine();
            outJ.newLine();

            outJ.write(DOCTYPE);
            outJ.write(" '");
            outJ.write(PREFS_DTD_NAME);
            outJ.write("'>");
            outJ.newLine();
            outJ.newLine();

            flushStartTag("preferences", new String[] { "EXTERNAL_XML_VERSION" },
                          new String[] { java.lang.StringJ.valueOf(XML_VERSION) }, outJ);
            flushStartTag("root", new String[] { "type" }, new String[] { prefs
                                                                          .isUserNode() ? "user" : "system" }, outJ);
            flushEmptyElement("map", outJ);

            StringTokenizer ancestors = new StringTokenizer(prefs.absolutePath(),
                                                            "/");

            exportNode(ancestors, prefs, withSubTree, outJ);

            flushEndTag("root", outJ);
            flushEndTag("preferences", outJ);
            outJ.flush();
            outJ = null;
        }
Example #4
0
 public void run()
 {
     java.io.OutputStream os = this.client.getOutputStream();
     os.write("Hello JavApi User".getBytes());
     os.flush();
     client.close();
 }
 public ZOutputStream(java.io.OutputStream outJ) : base()
 {
     this.outJ = outJ;
     z.inflateInit();
     compress = false;
     buf      = new byte[bufsize];
 }
Example #6
0
        /**
         * Create an archive output stream from an archiver name and an input stream.
         *
         * @param archiverName the archive name, i.e. "ar", "zip", "tar", "jar" or "cpio"
         * @param out the output stream
         * @return the archive output stream
         * @throws ArchiveException if the archiver name is not known
         * @throws IllegalArgumentException if the archiver name or stream is null
         */
        public ArchiveOutputStream createArchiveOutputStream(String archiverName, java.io.OutputStream outJ)
        //throws ArchiveException
        {
            if (archiverName == null)
            {
                throw new java.lang.IllegalArgumentException("Archivername must not be null.");
            }
            if (outJ == null)
            {
                throw new java.lang.IllegalArgumentException("OutputStream must not be null.");
            }

            if (AR.equalsIgnoreCase(archiverName))
            {
                return(new ArArchiveOutputStream(outJ));
            }
            if (ZIP.equalsIgnoreCase(archiverName))
            {
                return(new ZipArchiveOutputStream(outJ));
            }
            if (TAR.equalsIgnoreCase(archiverName))
            {
                return(new TarArchiveOutputStream(outJ));
            }
            if (JAR.equalsIgnoreCase(archiverName))
            {
                return(new JarArchiveOutputStream(outJ));
            }
            if (CPIO.equalsIgnoreCase(archiverName))
            {
                return(new CpioArchiveOutputStream(outJ));
            }
            throw new ArchiveException("Archiver: " + archiverName + " not found.");
        }
        /**
         * Create an compressor output stream from an compressor name and an input stream.
         *
         * @param name the compressor name, i.e. "gz" or "bzip2"
         * @param out the output stream
         * @return the compressor output stream
         * @throws CompressorException if the archiver name is not known
         * @throws IllegalArgumentException if the archiver name or stream is null
         */
        public CompressorOutputStream createCompressorOutputStream(
            String name, java.io.OutputStream outJ)
        //throws CompressorException
        {
            if (name == null || outJ == null)
            {
                throw new java.lang.IllegalArgumentException(
                          "Compressor name and stream must not be null.");
            }

            try {
                if (GZIP.Equals(name, StringComparison.OrdinalIgnoreCase))
                {
                    return(new GzipCompressorOutputStream(outJ));
                }

                if (BZIP2.Equals(name, StringComparison.OrdinalIgnoreCase))
                {
                    return(new BZip2CompressorOutputStream(outJ));
                }
            } catch (java.io.IOException e) {
                throw new CompressorException(
                          "Could not create CompressorOutputStream", e);
            }
            throw new CompressorException("Compressor: " + name + " not found.");
        }
Example #8
0
 /**
  * Constructs a {@code StreamHandler} object. The new stream handler
  * does not have an associated output stream.
  */
 public StreamHandler()
 {
     initProperties("INFO", null, "java.util.logging.SimpleFormatter", //$NON-NLS-1$//$NON-NLS-2$
                    null);
     this.os     = null;
     this.writer = null;
     this.writerNotInitialized = true;
 }
Example #9
0
 /**
  * Constructs a {@code StreamHandler} object. The new stream handler
  * does not have an associated output stream.
  */
 public StreamHandler()
 {
     initProperties("INFO", null, "java.util.logging.SimpleFormatter", //$NON-NLS-1$//$NON-NLS-2$
         null);
     this.os = null;
     this.writer = null;
     this.writerNotInitialized = true;
 }
 public ZOutputStream(java.io.OutputStream outJ)
     : base()
 {
     this.outJ=outJ;
     z.inflateInit();
     compress=false;
     buf = new byte[bufsize];
 }
 public ZOutputStream(java.io.OutputStream outJ, int level, bool nowrap)
     : base()
 {
     this.outJ=outJ;
     z.deflateInit(level, nowrap);
     compress=true;
     buf = new byte[bufsize];
 }
Example #12
0
 public Decode(SevenZip.Compression.LZMA.Decoder decoder, java.io.InputStream inputStream,
               java.io.OutputStream outputStream, long size)
     : base()
 {
     this.decoder      = decoder;
     this.inputStream  = inputStream;
     this.outputStream = outputStream;
     this.size         = size;
 }
Example #13
0
 /**
  * Constructs a {@code StreamHandler} object. The specified default values
  * will be used if the corresponding properties are not found in the log
  * manager's properties.
  */
 internal StreamHandler(String defaultLevel, String defaultFilter,
                        String defaultFormatter, String defaultEncoding)
 {
     initProperties(defaultLevel, defaultFilter, defaultFormatter,
                    defaultEncoding);
     this.os     = null;
     this.writer = null;
     this.writerNotInitialized = true;
 }
        /// <summary>
        /// Init the instance
        /// </summary>
        /// <param name="os">os the output stream to use</param>
        /// <param name="blockSize">blockSize the block size to use</param>
        /// <param name="recordSize">recordSize the record size to use</param>
        protected void init(java.io.OutputStream os, int blockSize, int recordSize)
        {
            outJ = os;

            this.buffer    = new TarBuffer(os, blockSize, recordSize);
            this.assemLen  = 0;
            this.assemBuf  = new byte[recordSize];
            this.recordBuf = new byte[recordSize];
        }
Example #15
0
 private long writeLong(java.io.OutputStream os, long i)  //throws java.io.IOException {
 // Write out the long value as an unsigned int
 {
     os.write((int)(i & 0xFF));
     os.write((int)(i >> 8) & 0xFF);
     os.write((int)(i >> 16) & 0xFF);
     os.write((int)(i >> 24) & 0xFF);
     return(i);
 }
Example #16
0
 public override void exportSubtree(java.io.OutputStream ostream) //throws IOException,
 {                                                                //BackingStoreException {
     if (ostream == null)
     {
         // prefs.5=Stream is null
         throw new java.lang.NullPointerException("Stream is null");                 //$NON-NLS-1$
     }
     checkState();
     XMLParser.exportPrefs(this, ostream, true);
 }
Example #17
0
 /**
  * Sets the output stream this handler writes to. If there's an existing
  * output stream, the tail string of the associated formatter will be
  * written to it. Then it will be flushed, closed and replaced with
  * {@code os}.
  *
  * @param os
  *            the new output stream.
  * @throws SecurityException
  *             if a security manager determines that the caller does not
  *             have the required permission.
  * @throws NullPointerException
  *             if {@code os} is {@code null}.
  */
 protected void setOutputStream(java.io.OutputStream os)
 {
     if (null == os)
     {
         throw new java.lang.NullPointerException();
     }
     LogManager.getLogManager().checkAccess();
     close(true);
     this.writer = null;
     this.os     = os;
     this.writerNotInitialized = true;
 }
 public override void close()//throws IOException {
 {
     try{
         try{ finish(); }
         catch (java.io.IOException) {}
     }
     finally{
         end();
         outJ.close();
         outJ = null;
     }
 }
Example #19
0
        /**
         * Copies the content of a InputStream into an OutputStream
         *
         * @param input
         *            the InputStream to copy
         * @param output
         *            the target Stream
         * @param buffersize
         *            the buffer size to use
         * @throws IOException
         *             if an error occurs
         */
        public static long copy(java.io.InputStream input, java.io.OutputStream output, int buffersize) //throws IOException
        {
            byte[] buffer = new byte[buffersize];
            int    n      = 0;
            long   count  = 0;

            while (-1 != (n = input.read(buffer)))
            {
                output.write(buffer, 0, n);
                count += n;
            }
            return(count);
        }
 /*
  * This constructor lets you specify both the compression algorithm as well
  * as the internal buffer size to be used.
  *
  * @param os
  *            is the {@code OutputStream} where to write the compressed data
  *            to.
  * @param def
  *            is the specific {@code Deflater} that will be used to compress
  *            data.
  * @param bsize
  *            is the size to be used for the internal buffer.
  */
 public DeflaterOutputStream(java.io.OutputStream os, Deflater def, int bsize) : base(os)
 {
     if (os == null || def == null)
     {
         throw new java.lang.NullPointerException();
     }
     if (bsize <= 0)
     {
         throw new java.lang.IllegalArgumentException();
     }
     this.def = def;
     buf      = new byte[bsize];
 }
Example #21
0
 /*
  * Constructs an InflaterOutputStream with the specifed Inflater and
  * internal output buffer size.
  *
  * @param out
  *            the output stream that InflaterOutputStream will write
  *            compressed data into.
  * @param infl
  *            the Inflater used by the InflaterOutputStream to decompress
  *            data.
  * @param bufLen the size of the internal output buffer.
  */
 public InflaterOutputStream(java.io.OutputStream outJ, Inflater infl, int bufLen) : base(outJ)
 {
     if (null == outJ || null == infl)
     {
         throw new java.lang.NullPointerException();
     }
     if (bufLen <= 0)
     {
         throw new java.lang.IllegalArgumentException();
     }
     inf = infl;
     buf = new byte[bufLen];
 }
Example #22
0
 /**
  * Constructs a {@code StreamHandler} object with the supplied output stream
  * and formatter.
  *
  * @param os
  *            the output stream this handler writes to.
  * @param formatter
  *            the formatter this handler uses to format the output.
  * @throws NullPointerException
  *             if {@code os} or {@code formatter} is {@code null}.
  */
 public StreamHandler(java.io.OutputStream os, Formatter formatter) : this()
 {
     if (os == null)
     {
         // logging.2=The OutputStream parameter is null
         throw new java.lang.NullPointerException("The OutputStream parameter is null");                 //$NON-NLS-1$
     }
     if (formatter == null)
     {
         // logging.3=The Formatter parameter is null.
         throw new java.lang.NullPointerException("The Formatter parameter is null.");                 //$NON-NLS-1$
     }
     this.os = os;
     internalSetFormatter(formatter);
 }
Example #23
0
        private void init(java.io.OutputStream outJ, short format, int blockSize)
        {
            this.outJ = outJ;
            switch (format)
            {
            case CpioConstants.FORMAT_NEW:
            case CpioConstants.FORMAT_NEW_CRC:
            case CpioConstants.FORMAT_OLD_ASCII:
            case CpioConstants.FORMAT_OLD_BINARY:
                break;

            default:
                throw new java.lang.IllegalArgumentException("Unknown format: " + format);
            }
            this.entryFormat = format;
            this.blockSize   = blockSize;
        }
 /**
  * Creates a new ZIP OutputStream writing to a File.  Will use
  * random access if possible.
  * @param file the file to zip to
  * @throws IOException on error
  */
 public ZipArchiveOutputStream(java.io.File file) //throws IOException
 {
     java.io.OutputStream     o    = null;
     java.io.RandomAccessFile _raf = null;
     try {
         _raf = new java.io.RandomAccessFile(file, "rw");
         _raf.setLength(0);
     } catch (java.io.IOException) {
         if (_raf != null)
         {
             try {
                 _raf.close();
             } catch (java.io.IOException) {
                 // ignore
             }
             _raf = null;
         }
         o = new java.io.FileOutputStream(file);
     }
     outJ = o;
     raf  = _raf;
 }
Example #25
0
        /**
         * Close the TarBuffer. If this is an output buffer, also flush the
         * current block before closing.
         * @throws IOException on error
         */
        public void close() //throws IOException
        {
            if (outStream != null)
            {
                flushBlock();

                if (outStream != java.lang.SystemJ.outJ &&
                    outStream != java.lang.SystemJ.err)
                {
                    outStream.close();

                    outStream = null;
                }
            }
            else if (inStream != null)
            {
                if (inStream != java.lang.SystemJ.inJ)
                {
                    inStream.close();

                    inStream = null;
                }
            }
        }
Example #26
0
 /**
  * Closes this handler, but the underlying output stream is only closed if
  * {@code closeStream} is {@code true}. Security is not checked.
  *
  * @param closeStream
  *            whether to close the underlying output stream.
  */
 protected void close(bool closeStream)
 {
     if (null != this.os)
     {
         if (this.writerNotInitialized)
         {
             initializeWritter();
         }
         write(getFormatter().getTail(this));
         try {
             this.writer.flush();
             if (closeStream)
             {
                 this.writer.close();
                 this.writer = null;
                 this.os     = null;
             }
         } catch (java.lang.Exception e) {
             // logging.15=Exception occurred when closing the output stream.
             getErrorManager().error("Exception occurred when closing the output stream.", e,                     //$NON-NLS-1$
                                     ErrorManager.CLOSE_FAILURE);
         }
     }
 }
Example #27
0
 public MeasureOutputStream(java.io.OutputStream stream) :
     this(stream, 0)
 {
 }
Example #28
0
 /*
  * Constructs an InflaterOutputStream with the default Inflater and internal
  * output buffer size.
  *
  * @param out
  *            the output stream that InflaterOutputStream will write
  *            compressed data into.
  */
 public InflaterOutputStream(java.io.OutputStream outJ) : this(outJ, new Inflater())
 {
 }
 public override void close()
 {
     //throws IOException {
     try{
       try{finish();}
       catch (java.io.IOException/* ignored */) {}
     }
     finally{
       end();
       outJ.close();
       outJ=null;
     }
 }
Example #30
0
 public MeasureOutputStream(java.io.OutputStream stream, long currentLength)
 {
     wrapped = stream;
     length  = currentLength;
 }
Example #31
0
 /**
  * Constructs a {@code StreamHandler} object with the supplied output
  * stream. Default properties are read.
  *
  * @param os
  *            the output stream this handler writes to.
  */
 internal StreamHandler(java.io.OutputStream os)
     : this()
 {
     this.os = os;
 }
Example #32
0
 public StreamWrapper(java.io.InputStream input, java.io.OutputStream output)
 {
     this.input = input;
     this.output = output;
 }
Example #33
0
 /*
  * Constructs a new {@code ZipOutputStream} with the specified output
  * stream.
  *
  * @param p1
  *            the {@code OutputStream} to write the data to.
  */
 public ZipOutputStream(java.io.OutputStream p1) : base(p1, new Deflater(Deflater.DEFAULT_COMPRESSION, true))
 {
 }
Example #34
0
 /**
  * Closes this handler, but the underlying output stream is only closed if
  * {@code closeStream} is {@code true}. Security is not checked.
  *
  * @param closeStream
  *            whether to close the underlying output stream.
  */
 protected void close(bool closeStream)
 {
     if (null != this.os) {
     if (this.writerNotInitialized) {
         initializeWritter();
     }
     write(getFormatter().getTail(this));
     try {
         this.writer.flush();
         if (closeStream) {
             this.writer.close();
             this.writer = null;
             this.os = null;
         }
     } catch (java.lang.Exception e) {
         // logging.15=Exception occurred when closing the output stream.
             getErrorManager().error("Exception occurred when closing the output stream.", e, //$NON-NLS-1$
                 ErrorManager.CLOSE_FAILURE);
     }
     }
 }
Example #35
0
 /**
  * Constructs a {@code StreamHandler} object. The specified default values
  * will be used if the corresponding properties are not found in the log
  * manager's properties.
  */
 internal StreamHandler(String defaultLevel, String defaultFilter,
     String defaultFormatter, String defaultEncoding)
 {
     initProperties(defaultLevel, defaultFilter, defaultFormatter,
         defaultEncoding);
     this.os = null;
     this.writer = null;
     this.writerNotInitialized = true;
 }
Example #36
0
 private int writeShort(java.io.OutputStream os, int i)  //throws java.io.IOException {
 {
     os.write(i & 0xFF);
     os.write((i >> 8) & 0xFF);
     return(i);
 }
Example #37
0
 /**
  * Constructs a {@code StreamHandler} object with the supplied output stream
  * and formatter.
  *
  * @param os
  *            the output stream this handler writes to.
  * @param formatter
  *            the formatter this handler uses to format the output.
  * @throws NullPointerException
  *             if {@code os} or {@code formatter} is {@code null}.
  */
 public StreamHandler(java.io.OutputStream os, Formatter formatter)
     : this()
 {
     if (os == null) {
     // logging.2=The OutputStream parameter is null
         throw new java.lang.NullPointerException("The OutputStream parameter is null"); //$NON-NLS-1$
     }
     if (formatter == null) {
     // logging.3=The Formatter parameter is null.
         throw new java.lang.NullPointerException("The Formatter parameter is null."); //$NON-NLS-1$
     }
     this.os = os;
     internalSetFormatter(formatter);
 }
Example #38
0
 /**
  * Sets the output stream this handler writes to. Note it does nothing else.
  *
  * @param newOs
  *            the new output stream
  */
 internal void internalSetOutputStream(java.io.OutputStream newOs)
 {
     this.os = newOs;
 }
Example #39
0
 public MeasureOutputStream(java.io.OutputStream stream, long currentLength)
 {
     wrapped = stream;
     length = currentLength;
 }
Example #40
0
 /*
  * Constructs an InflaterOutputStream with the specifed Inflater and the
  * default internal output buffer size.
  *
  * @param out
  *            the output stream that InflaterOutputStream will write
  *            compressed data into.
  * @param infl
  *            the Inflater used by the InflaterOutputStream to decompress
  *            data.
  */
 public InflaterOutputStream(java.io.OutputStream outJ, Inflater infl) : this(outJ, infl, DEFAULT_BUFFER_SIZE)
 {
 }
Example #41
0
 public StreamWrapper(java.io.InputStream input, java.io.OutputStream output)
 {
     this.input  = input;
     this.output = output;
 }
 public OutputStreamWrapper(java.io.OutputStream outputStream)
 {
     this.delegateInstance = outputStream;
 }
Example #43
0
 /**
  * Sets the output stream this handler writes to. If there's an existing
  * output stream, the tail string of the associated formatter will be
  * written to it. Then it will be flushed, closed and replaced with
  * {@code os}.
  *
  * @param os
  *            the new output stream.
  * @throws SecurityException
  *             if a security manager determines that the caller does not
  *             have the required permission.
  * @throws NullPointerException
  *             if {@code os} is {@code null}.
  */
 protected void setOutputStream(java.io.OutputStream os)
 {
     if (null == os) {
     throw new java.lang.NullPointerException();
     }
     LogManager.getLogManager().checkAccess();
     close(true);
     this.writer = null;
     this.os = os;
     this.writerNotInitialized = true;
 }