Exemple #1
0
 /// <summary>
 /// Constructs a new
 /// <code>PrintStream</code>
 /// with
 /// <code>out</code>
 /// as its target
 /// stream. By default, the new print stream does not automatically flush its
 /// contents to the target stream when a newline is encountered.
 /// </summary>
 /// <param name="out">the target output stream.</param>
 /// <exception cref="System.ArgumentNullException">
 /// if
 /// <code>out</code>
 /// is
 /// <code>null</code>
 /// .
 /// </exception>
 public PrintStream(java.io.OutputStream @out) : base(@out)
 {
     if (@out == null)
     {
         throw new System.ArgumentNullException();
     }
 }
Exemple #2
0
 /// <summary>
 /// Constructs a new OutputStreamWriter using
 /// <code>out</code>
 /// as the target
 /// stream to write converted characters to and
 /// <code>enc</code>
 /// as the character
 /// encoder.
 /// </summary>
 /// <param name="out">the target stream to write converted bytes to.</param>
 /// <param name="enc">the character encoder used for character conversion.</param>
 public OutputStreamWriter(java.io.OutputStream @out, java.nio.charset.CharsetEncoder
                           enc) : base(@out)
 {
     enc.charset();
     this.@out = @out;
     encoder   = enc;
 }
        /// <summary>
        /// Releases the unmanaged resources used by this
        /// <see cref="System.IO.Stream"/> and optionally
        /// releases the managed resources.
        /// </summary>
        /// <remarks>
        /// Calling this method with <c>true</c> effectively
        /// closes and nullifies this object's underlying
        /// java.io.OutputStream.  However, calling Close()
        /// is the preferred method.
        /// </remarks>
        /// <param name="disposing">
        /// True to release both managed and unmanaged resources;
        /// false to release only unmanaged resources.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                lock (this)
                {
                    try
                    {
                        if (m_out != null)
                        {
                            m_out.close();
                        }
                    }
                    catch (java.io.IOException ex)
                    {
                        throw new IOException(ex.ToString(), ex);
                    }
                    finally
                    {
                        m_out = null;

                        base.Dispose(disposing);
                    }
                }
            }
            else
            {
                base.Dispose(disposing);
            }
        }
Exemple #4
0
 /// <summary>
 /// Constructs a new
 /// <code>PrintStream</code>
 /// with
 /// <code>out</code>
 /// as its target
 /// stream. The parameter
 /// <code>autoFlush</code>
 /// determines if the print stream
 /// automatically flushes its contents to the target stream when a newline is
 /// encountered.
 /// </summary>
 /// <param name="out">the target output stream.</param>
 /// <param name="autoFlush">
 /// indicates whether to flush contents upon encountering a
 /// newline sequence.
 /// </param>
 /// <exception cref="System.ArgumentNullException">
 /// if
 /// <code>out</code>
 /// is
 /// <code>null</code>
 /// .
 /// </exception>
 public PrintStream(java.io.OutputStream @out, bool autoFlush) : base(@out)
 {
     if (@out == null)
     {
         throw new System.ArgumentNullException();
     }
     this.autoFlush = autoFlush;
 }
Exemple #5
0
 /// <summary>
 /// Constructs a new OutputStreamWriter using
 /// <code>out</code>
 /// as the target
 /// stream to write converted characters to and
 /// <code>cs</code>
 /// as the character
 /// encoding.
 /// </summary>
 /// <param name="out">the target stream to write converted bytes to.</param>
 /// <param name="cs">
 /// the
 /// <code>Charset</code>
 /// that specifies the character encoding.
 /// </param>
 public OutputStreamWriter(java.io.OutputStream @out, java.nio.charset.Charset cs)
     : base(@out)
 {
     this.@out = @out;
     encoder   = cs.newEncoder();
     encoder.onMalformedInput(java.nio.charset.CodingErrorAction.REPLACE);
     encoder.onUnmappableCharacter(java.nio.charset.CodingErrorAction.REPLACE);
 }
Exemple #6
0
 /// <summary>
 /// Constructs a new
 /// <code>BufferedOutputStream</code>
 /// , providing
 /// <code>out</code>
 /// with
 /// <code>size</code>
 /// bytes
 /// of buffer.
 /// </summary>
 /// <param name="out">
 /// the
 /// <code>OutputStream</code>
 /// the buffer writes to.
 /// </param>
 /// <param name="size">the size of buffer in bytes.</param>
 /// <exception cref="System.ArgumentException">
 /// if
 /// <code>size &lt;= 0</code>
 /// .
 /// </exception>
 public BufferedOutputStream(java.io.OutputStream @out, int size) : base(@out)
 {
     if (size <= 0)
     {
         throw new System.ArgumentException("size <= 0");
     }
     buf = new byte[size];
 }
        public JavaOutputStreamWrapper(java.io.OutputStream outputStream)
        {
            if (outputStream == null)
            {
                throw new ArgumentNullException("outputStream");
            }

            m_out = outputStream;
        }
        public JavaOutputStreamWrapper(java.io.OutputStream outputStream)
        {
            if (outputStream == null)
            {
                throw new ArgumentNullException("outputStream");
            }

            m_out = outputStream;
        }
Exemple #9
0
 private Socket(rtl.SOCKET handle)
         #endif
 {
     fHandle = handle;
                 #if cooper
     fSocketInput  = fHandle.getInputStream();
     fSocketOutput = fHandle.getOutputStream();
                 #endif
 }
Exemple #10
0
        /// <summary>Specify the destination of the serialized output, in the
        /// form of a file name</summary>
        /// <param name="filename">The name of the file to receive the serialized output</param>
        /// <exception>Throws a <c>DyamicError</c> if it is not possible to create an output
        /// stream to write to this file, for example, if the filename is in a directory
        /// that does not exist.</exception>

        public void SetOutputFile(String filename)
        {
            try {
                outputStream = new JFileOutputStream(filename);
                mustClose    = true;
            } catch (java.io.IOException err) {
                JDynamicError e = new JDynamicError(err);
                throw new DynamicError(e);
            }
        }
Exemple #11
0
        /// <summary>
        /// CopyStream
        /// </summary>

        public static void CopyStream(java.io.InputStream from, java.io.OutputStream to)
        {
            sbyte[] buffer = new sbyte[8192];
            int     got;

            while ((got = from.read(buffer, 0, buffer.Length)) > 0)
            {
                to.write(buffer, 0, got);
            }
        }
Exemple #12
0
 internal override bool checkError()
 {
     java.io.OutputStream @delegate = @out;
     if (@delegate == null)
     {
         return(ioError);
     }
     flush();
     return(ioError || @delegate.checkError());
 }
Exemple #13
0
        /// <summary>
        /// Opens the connection.
        /// </summary>
        /// <param name="host">The host.</param>
        /// <param name="port">The port.</param>
        /// <param name="tls">
        /// if set to <c>true</c>, use transport layer security.
        /// </param>
        /// <exception cref="HsqlException">
        /// </exception>
        protected virtual void OpenConnection(
            string host,
            int port,
            bool tls)
        {
            if (m_tcpClient != null)
            {
                throw new System.InvalidOperationException(
                          "The connection is already open.");
            }

            HsqlDiagnostics.Debug("...");

            try
            {
                HsqlDiagnostics.Debug("Entered with arguments ({0},{1},{2})",
                                      host, port, tls);

                m_tcpClient = new TcpClient(host, port);

                HsqlDiagnostics.Debug("Created TcpClient({0},{1})", host, port);

                Stream stream = m_tcpClient.GetStream();

                HsqlDiagnostics.Debug("Got client stream from TcpClient");

                if (m_tls)
                {
                    HsqlDiagnostics.Debug("Initializing Client TLS...");

                    SslStream sslStream = new SslStream(
                        stream,
                        false,
                        ValidateRemoteCertificate,
                        null);

                    HsqlDiagnostics.Debug("Invoking sslStream.AuthenticateAsClient({0})",
                                          host);

                    sslStream.AuthenticateAsClient(host);

                    stream = sslStream;
                }

                JavaInputStreamAdapter  input  = new JavaInputStreamAdapter(stream);
                JavaOutputStreamAdapter output = new JavaOutputStreamAdapter(stream);

                m_dataInput  = new DataInputStream(new BufferedInputStream(input));
                m_dataOutput = new BufferedOutputStream(output);
            }
            catch (System.Exception e)
            {
                throw Trace.error(Trace.SOCKET_ERROR, e);
            }
        }
Exemple #14
0
 public virtual void storeToXML(java.io.OutputStream arg0, java.lang.String arg1)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         @__env.CallVoidMethod(this.JvmHandle, global::java.util.Properties._storeToXML15615, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1));
     }
     else
     {
         @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::java.util.Properties.staticClass, global::java.util.Properties._storeToXML15615, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1));
     }
 }
Exemple #15
0
 public virtual void writeToStream(java.io.OutputStream arg0)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         @__env.CallVoidMethod(this.JvmHandle, global::android.graphics.Picture._writeToStream3610, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0));
     }
     else
     {
         @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.graphics.Picture.staticClass, global::android.graphics.Picture._writeToStream3610, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0));
     }
 }
Exemple #16
0
 void org.xmlpull.v1.XmlSerializer.setOutput(java.io.OutputStream arg0, java.lang.String arg1)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         @__env.CallVoidMethod(this.JvmHandle, global::org.xmlpull.v1.XmlSerializer_._setOutput16606, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1));
     }
     else
     {
         @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::org.xmlpull.v1.XmlSerializer_.staticClass, global::org.xmlpull.v1.XmlSerializer_._setOutput16606, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1));
     }
 }
Exemple #17
0
 public override void engineStore(java.io.OutputStream arg0, char[] arg1)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         @__env.CallVoidMethod(this.JvmHandle, global::java.security.KeyStoreSpi_._engineStore14846, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1));
     }
     else
     {
         @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::java.security.KeyStoreSpi_.staticClass, global::java.security.KeyStoreSpi_._engineStore14846, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1));
     }
 }
Exemple #18
0
 public bool compress(android.graphics.Bitmap.CompressFormat arg0, int arg1, java.io.OutputStream arg2)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         return(@__env.CallBooleanMethod(this.JvmHandle, global::android.graphics.Bitmap._compress3105, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2)));
     }
     else
     {
         return(@__env.CallNonVirtualBooleanMethod(this.JvmHandle, global::android.graphics.Bitmap.staticClass, global::android.graphics.Bitmap._compress3105, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2)));
     }
 }
Exemple #19
0
 public virtual void save(java.io.OutputStream arg0)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         @__env.CallVoidMethod(this.JvmHandle, global::android.gesture.GestureStore._save3036, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0));
     }
     else
     {
         @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.gesture.GestureStore.staticClass, global::android.gesture.GestureStore._save3036, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0));
     }
 }
Exemple #20
0
 public virtual bool compressToJpeg(android.graphics.Rect arg0, int arg1, java.io.OutputStream arg2)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         return(@__env.CallBooleanMethod(this.JvmHandle, global::android.graphics.YuvImage._compressToJpeg3825, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2)));
     }
     else
     {
         return(@__env.CallNonVirtualBooleanMethod(this.JvmHandle, global::android.graphics.YuvImage.staticClass, global::android.graphics.YuvImage._compressToJpeg3825, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2)));
     }
 }
Exemple #21
0
 void org.apache.http.HttpEntity.writeTo(java.io.OutputStream arg0)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         @__env.CallVoidMethod(this.JvmHandle, global::org.apache.http.HttpEntity_._writeTo16147, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0));
     }
     else
     {
         @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::org.apache.http.HttpEntity_.staticClass, global::org.apache.http.HttpEntity_._writeTo16147, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0));
     }
 }
Exemple #22
0
 /// <exception cref="System.IO.IOException"/>
 public virtual void open()
 {
     lock (this)
     {
         if (this.isOpen())
         {
             return;
         }
         if (this.useSsl != null && this.useSsl)
         {
             if (this.sslContext != null)
             {
                 this.socket = this.sslContext.getSocketFactory().createSocket();
             }
             else
             {
                 this.socket = javax.net.ssl.SSLSocketFactory.getDefault().createSocket();
             }
         }
         else
         {
             this.socket = javax.net.SocketFactory.getDefault().createSocket();
         }
         string host = this.host != null ? this.host : ArangoDBConstants
                       .DEFAULT_HOST;
         int port = this.port != null ? this.port : ArangoDBConstants
                    .DEFAULT_PORT;
         if (LOGGER.isDebugEnabled())
         {
             LOGGER.debug(string.format("Open connection to addr=%s,port=%s", host, port));
         }
         this.socket.connect(new java.net.InetSocketAddress(host, port), this.timeout != null ? this.timeout
              : ArangoDBConstants.DEFAULT_TIMEOUT);
         this.socket.setKeepAlive(true);
         this.socket.setTcpNoDelay(true);
         if (LOGGER.isDebugEnabled())
         {
             LOGGER.debug(string.format("Connected to %s", this.socket));
         }
         this.outputStream = new java.io.BufferedOutputStream(this.socket.getOutputStream());
         this.inputStream  = this.socket.getInputStream();
         if (this.useSsl != null && this.useSsl)
         {
             if (LOGGER.isDebugEnabled())
             {
                 LOGGER.debug(string.format("Start Handshake on %s", this.socket));
             }
             ((javax.net.ssl.SSLSocket) this.socket).startHandshake();
         }
         this.sendProtocolHeader();
     }
 }
Exemple #23
0
 private void StartInstanceBlocked()
 {
     if (interpreter == null)
     {
         if (UseStreams)
         {
             outStream   = getOutputStream();
             inStream    = getInputStream();
             interpreter = Interpreter.createJLispInstance(inStream, outStream, ".", VersionString);
             return;
         }
         interpreter = Interpreter.createDefaultInstance(new String[0]);
     }
 }
Exemple #24
0
        /// <summary>
        /// Copies all of the bytes from
        /// <code>in</code>
        /// to
        /// <code>out</code>
        /// . Neither stream is closed.
        /// Returns the total number of bytes transferred.
        /// </summary>
        /// <exception cref="System.IO.IOException"></exception>
        public static int copy(java.io.InputStream @in, java.io.OutputStream @out)
        {
            int total = 0;

            byte[] buffer = new byte[8192];
            int    c;

            while ((c = @in.read(buffer)) != -1)
            {
                total += c;
                @out.write(buffer, 0, c);
            }
            return(total);
        }
Exemple #25
0
 public void writeRequest(java.io.OutputStream output)
 {
     if (_out != null)
     {
         _buffer = _out.toByteArray();
     }
     if (_buffer != null)
     {
         output.write(_buffer, 0, _buffer.Length);
         _out = null;
     }
     else
     {
         throw new ApplicationException();
     }
 }
Exemple #26
0
 /// <summary>
 /// Constructs a new OutputStreamWriter using
 /// <code>out</code>
 /// as the target
 /// stream to write converted characters to and
 /// <code>enc</code>
 /// as the character
 /// encoding. If the encoding cannot be found, an
 /// UnsupportedEncodingException error is thrown.
 /// </summary>
 /// <param name="out">the target stream to write converted bytes to.</param>
 /// <param name="enc">the string describing the desired character encoding.</param>
 /// <exception cref="System.ArgumentNullException">
 /// if
 /// <code>enc</code>
 /// is
 /// <code>null</code>
 /// .
 /// </exception>
 /// <exception cref="UnsupportedEncodingException">
 /// if the encoding specified by
 /// <code>enc</code>
 /// cannot be found.
 /// </exception>
 /// <exception cref="java.io.UnsupportedEncodingException"></exception>
 public OutputStreamWriter(java.io.OutputStream @out, string enc) : base(@out)
 {
     if (enc == null)
     {
         throw new System.ArgumentNullException();
     }
     this.@out = @out;
     try
     {
         encoder = java.nio.charset.Charset.forName(enc).newEncoder();
     }
     catch (System.Exception)
     {
         throw new java.io.UnsupportedEncodingException(enc);
     }
     encoder.onMalformedInput(java.nio.charset.CodingErrorAction.REPLACE);
     encoder.onUnmappableCharacter(java.nio.charset.CodingErrorAction.REPLACE);
 }
		/// <summary>
		/// Constructs a new OutputStreamWriter using
		/// <code>out</code>
		/// as the target
		/// stream to write converted characters to and
		/// <code>enc</code>
		/// as the character
		/// encoding. If the encoding cannot be found, an
		/// UnsupportedEncodingException error is thrown.
		/// </summary>
		/// <param name="out">the target stream to write converted bytes to.</param>
		/// <param name="enc">the string describing the desired character encoding.</param>
		/// <exception cref="System.ArgumentNullException">
		/// if
		/// <code>enc</code>
		/// is
		/// <code>null</code>
		/// .
		/// </exception>
		/// <exception cref="UnsupportedEncodingException">
		/// if the encoding specified by
		/// <code>enc</code>
		/// cannot be found.
		/// </exception>
		/// <exception cref="java.io.UnsupportedEncodingException"></exception>
		public OutputStreamWriter(java.io.OutputStream @out, string enc) : base(@out)
		{
			if (enc == null)
			{
				throw new System.ArgumentNullException();
			}
			this.@out = @out;
			try
			{
				encoder = java.nio.charset.Charset.forName(enc).newEncoder();
			}
			catch (System.Exception)
			{
				throw new java.io.UnsupportedEncodingException(enc);
			}
			encoder.onMalformedInput(java.nio.charset.CodingErrorAction.REPLACE);
			encoder.onUnmappableCharacter(java.nio.charset.CodingErrorAction.REPLACE);
		}
Exemple #28
0
        public void Connect(EndPoint remoteEP)
        {
            var lEndPoint = (IPEndPoint)remoteEP;

                        #if cooper
            var lAddress = java.net.InetAddress.getByAddress(lEndPoint.Address.GetAddressBytes());
            fHandle       = new java.net.Socket(lAddress, lEndPoint.Port);
            fSocketInput  = fHandle.getInputStream();
            fSocketOutput = fHandle.getOutputStream();
                        #else
            void *lPointer;
            int   lSize;
                        #if posix || toffee || darwin || android
            rtl.__struct_sockaddr_in  lIPv4;
            rtl.__struct_sockaddr_in6 lIPv6;
                        #if posix && !darwin && !android
            rtl.__CONST_SOCKADDR_ARG lSockAddr;
                        #else
            rtl.__struct_sockaddr lSockAddr;
                        #endif
                        #else
            rtl.SOCKADDR_IN lIPv4;
            sockaddr_in6    lIPv6;
                        #endif


            IPEndPointToNative(lEndPoint, out lIPv4, out lIPv6, out lPointer, out lSize);
            var lRes = 0;
                        #if posix && !darwin && !android
            lSockAddr.__sockaddr__ = (rtl.__struct_sockaddr *)lPointer;
            lRes = rtl.connect(fHandle, lSockAddr, lSize);
                        #elif toffee || darwin || android
            lRes = rtl.connect(fHandle, (rtl.__struct_sockaddr *)lPointer, lSize);
                        #else
            lRes = rtl.connect(fHandle, lPointer, lSize);
                        #endif
            if (lRes != 0)
            {
                throw new Exception("Error connecting socket");
            }
                        #endif

            Connected = true;
        }
Exemple #29
0
 /// <summary>
 /// Constructs a new
 /// <code>PrintStream</code>
 /// with
 /// <code>out</code>
 /// as its target
 /// stream and using the character encoding
 /// <code>enc</code>
 /// while writing. The
 /// parameter
 /// <code>autoFlush</code>
 /// determines if the print stream automatically
 /// flushes its contents to the target stream when a newline is encountered.
 /// </summary>
 /// <param name="out">the target output stream.</param>
 /// <param name="autoFlush">
 /// indicates whether or not to flush contents upon encountering a
 /// newline sequence.
 /// </param>
 /// <param name="enc">the non-null string describing the desired character encoding.</param>
 /// <exception cref="System.ArgumentNullException">
 /// if
 /// <code>out</code>
 /// or
 /// <code>enc</code>
 /// are
 /// <code>null</code>
 /// .
 /// </exception>
 /// <exception cref="UnsupportedEncodingException">
 /// if the encoding specified by
 /// <code>enc</code>
 /// is not supported.
 /// </exception>
 /// <exception cref="java.io.UnsupportedEncodingException"></exception>
 public PrintStream(java.io.OutputStream @out, bool autoFlush, string enc) : base(
         @out)
 {
     if (@out == null || enc == null)
     {
         throw new System.ArgumentNullException();
     }
     this.autoFlush = autoFlush;
     try
     {
         if (!java.nio.charset.Charset.isSupported(enc))
         {
             throw new java.io.UnsupportedEncodingException(enc);
         }
     }
     catch (java.nio.charset.IllegalCharsetNameException)
     {
         throw new java.io.UnsupportedEncodingException(enc);
     }
     encoding = enc;
 }
Exemple #30
0
        protected override void saveImage(ui.Image image, java.io.OutputStream response, string format, float quality)
        {
            CanvasBitmapFileFormat fileFormat = CanvasBitmapFileFormat.Png;

            if (format.Equals(FORMAT_JPEG))
            {
                fileFormat = CanvasBitmapFileFormat.Jpeg;
            }
            CodenameOneImage           img = (CodenameOneImage)image.getImage();
            CanvasBitmap               cb  = img.image;
            InMemoryRandomAccessStream ms  = new InMemoryRandomAccessStream();

            cb.SaveAsync(ms, fileFormat, quality).AsTask().ConfigureAwait(false).GetAwaiter().GetResult();;
            ms.Seek(0);
            byte[]     buf = new byte[ms.Size];
            DataReader dr  = new DataReader(ms);

            dr.LoadAsync((uint)ms.Size).AsTask().ConfigureAwait(false).GetAwaiter().GetResult();;
            dr.ReadBytes(buf);
            response.write(buf);
        }
Exemple #31
0
        public override void save(java.io.InputStream image, java.io.OutputStream response, string format, int width, int height, float quality)
        {
            CanvasBitmapFileFormat fileFormat = CanvasBitmapFileFormat.Png;

            if (format.Equals(FORMAT_JPEG))
            {
                fileFormat = CanvasBitmapFileFormat.Jpeg;
            }
            CodenameOneImage           img         = (CodenameOneImage)SilverlightImplementation.instance.createImage(image);
            CodenameOneImage           scaledImage = (CodenameOneImage)SilverlightImplementation.instance.scale(img, width, height);
            InMemoryRandomAccessStream ms          = new InMemoryRandomAccessStream();

            scaledImage.image.SaveAsync(ms, fileFormat, quality).AsTask().ConfigureAwait(false).GetAwaiter().GetResult();
            ms.Seek(0);
            byte[]     buf = new byte[ms.Size];
            DataReader dr  = new DataReader(ms);

            dr.LoadAsync((uint)ms.Size).AsTask().ConfigureAwait(false).GetAwaiter().GetResult();
            dr.ReadBytes(buf);
            response.write(buf);
        }
        /// <summary>
        /// Releases the unmanaged resources used by this
        /// <see cref="System.IO.Stream"/> and optionally
        /// releases the managed resources.
        /// </summary>
        /// <remarks>
        /// Calling this method with <c>true</c> effectively
        /// closes and nullifies this object's underlying
        /// java.io.OutputStream.  However, calling Close()
        /// is the preferred method.
        /// </remarks>
        /// <param name="disposing">
        /// True to release both managed and unmanaged resources;
        /// false to release only unmanaged resources.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                lock (this)
                {
                    try
                    {
                        if (m_out != null)
                        {
                            m_out.close();
                        }
                    }
                    catch (java.io.IOException ex)
                    {
                        throw new IOException(ex.ToString(), ex);
                    }
                    finally
                    {
                        m_out = null;

                        base.Dispose(disposing);
                    }
                }
            }
            else
            {
                base.Dispose(disposing);
            }
        }
 public override void open(java.io.RandomOutputStream stream)
 {
     @out = stream;
 }
Exemple #34
0
 /// <summary>Open the output file.</summary>
 /// <remarks>Open the output file.</remarks>
 /// <param name="file">- file to open.</param>
 /// <exception>
 /// IOException
 /// if there was an exception opening the Audio Writer.
 /// </exception>
 /// <exception cref="System.IO.IOException"></exception>
 public override void open(java.io.File file)
 {
     file.delete();
     @out = new java.io.FileOutputStream(file);
 }
		/// <summary>
		/// Constructs a new OutputStreamWriter using
		/// <code>out</code>
		/// as the target
		/// stream to write converted characters to and
		/// <code>cs</code>
		/// as the character
		/// encoding.
		/// </summary>
		/// <param name="out">the target stream to write converted bytes to.</param>
		/// <param name="cs">
		/// the
		/// <code>Charset</code>
		/// that specifies the character encoding.
		/// </param>
		public OutputStreamWriter(java.io.OutputStream @out, java.nio.charset.Charset cs)
			 : base(@out)
		{
			this.@out = @out;
			encoder = cs.newEncoder();
			encoder.onMalformedInput(java.nio.charset.CodingErrorAction.REPLACE);
			encoder.onUnmappableCharacter(java.nio.charset.CodingErrorAction.REPLACE);
		}
		/// <summary>
		/// Constructs a new
		/// <code>FilterOutputStream</code>
		/// with
		/// <code>out</code>
		/// as its
		/// target stream.
		/// </summary>
		/// <param name="out">the target stream that this stream writes to.</param>
		public FilterOutputStream(java.io.OutputStream @out)
		{
			this.@out = @out;
		}
 private void StartInstanceBlocked()
 {
     if (interpreter == null)
     {
         if (UseStreams)
         {
             outStream = getOutputStream();
             inStream = getInputStream();
             interpreter = Interpreter.createJLispInstance(inStream, outStream, ".", VersionString);
             return;
         }
         interpreter = Interpreter.createDefaultInstance(new String[0]);
     }
 }
			internal VMWRequestStream (java.io.OutputStream stream, long contentLength)
			{
				_javaOutput = stream;
				_contentLength = contentLength;
				_len = 0;
			}
        /// <summary>
        /// Opens the connection.
        /// </summary>
        /// <param name="host">The host.</param>
        /// <param name="port">The port.</param>
        /// <param name="tls">
        /// if set to <c>true</c>, use transport layer security.
        /// </param>
        /// <exception cref="HsqlException">
        /// </exception>
        protected virtual void OpenConnection(
            string host,
            int port,
            bool tls)
        {
            if (m_tcpClient != null)
            {
                throw new System.InvalidOperationException(
                    "The connection is already open.");
            }

            HsqlDiagnostics.Debug("...");

            try
            {
                HsqlDiagnostics.Debug("Entered with arguments ({0},{1},{2})",
                    host, port, tls);

                m_tcpClient = new TcpClient(host, port);

                HsqlDiagnostics.Debug("Created TcpClient({0},{1})", host, port);

                Stream stream = m_tcpClient.GetStream();

                HsqlDiagnostics.Debug("Got client stream from TcpClient");

                if (m_tls)
                {
                    HsqlDiagnostics.Debug("Initializing Client TLS...");

                    SslStream sslStream = new SslStream(
                        stream,
                        false,
                        ValidateRemoteCertificate,
                        null);

                    HsqlDiagnostics.Debug("Invoking sslStream.AuthenticateAsClient({0})",
                        host);

                    sslStream.AuthenticateAsClient(host);

                    stream = sslStream;
                }

                JavaInputStreamAdapter input = new JavaInputStreamAdapter(stream);
                JavaOutputStreamAdapter output = new JavaOutputStreamAdapter(stream);

                m_dataInput = new DataInputStream(new BufferedInputStream(input));
                m_dataOutput = new BufferedOutputStream(output);
            }
            catch (System.Exception e)
            {
                throw Trace.error(Trace.SOCKET_ERROR, e);
            }
        }
        /// <summary>Specify the destination of the serialized output, in the
        /// form of a file name</summary>
        /// <param name="filename">The name of the file to receive the serialized output</param>
        /// <exception>Throws a <c>DyamicError</c> if it is not possible to create an output
        /// stream to write to this file, for example, if the filename is in a directory
        /// that does not exist.</exception>

        public void SetOutputFile(String filename) {
            try {
                outputStream = new JFileOutputStream(filename);
                mustClose = true;
            } catch (java.io.IOException err) {
                JDynamicError e = new JDynamicError(err);
                throw new DynamicError(e);
            }
        }
        /// <summary>Specify the destination of the serialized output, in the
        /// form of a <c>Stream</c></summary>
        /// <param name="stream">The stream to which the output will be written.
        /// This must be a stream that allows writing.</param>

        public void SetOutputStream(Stream stream) {
            outputStream = new DotNetOutputStream(stream);
            mustClose = false;
        }
Exemple #42
0
 public abstract void engineStore(java.io.OutputStream arg0, char[] arg1);
		/// <summary>
		/// Constructs a new OutputStreamWriter using
		/// <code>out</code>
		/// as the target
		/// stream to write converted characters to and
		/// <code>enc</code>
		/// as the character
		/// encoder.
		/// </summary>
		/// <param name="out">the target stream to write converted bytes to.</param>
		/// <param name="enc">the character encoder used for character conversion.</param>
		public OutputStreamWriter(java.io.OutputStream @out, java.nio.charset.CharsetEncoder
			 enc) : base(@out)
		{
			enc.charset();
			this.@out = @out;
			encoder = enc;
		}