/// <exception cref="System.IO.IOException"></exception>
        private void CreateBytes(ISerializable ser)
        {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ObjectOutputStream    @out = new ObjectOutputStream(baos);

            @out.WriteObject(ser);
            @out.Flush();
            this.objSer = baos.ToByteArray();
        }
 /// <exception cref="System.IO.IOException"></exception>
 public override void WriteTo(OutputStream outstream)
 {
     Args.NotNull(outstream, "Output stream");
     if (this.objSer == null)
     {
         ObjectOutputStream @out = new ObjectOutputStream(outstream);
         @out.WriteObject(this.objRef);
         @out.Flush();
     }
     else
     {
         outstream.Write(this.objSer);
         outstream.Flush();
     }
 }
Exemple #3
0
        /// <summary>
        /// Constructs a SignedObject from any Serializable object.
        /// The given object is signed with the given signing key, using the
        /// designated signature engine.
        /// </summary>
        /// <param name="object"> the object to be signed. </param>
        /// <param name="signingKey"> the private key for signing. </param>
        /// <param name="signingEngine"> the signature signing engine.
        /// </param>
        /// <exception cref="IOException"> if an error occurs during serialization </exception>
        /// <exception cref="InvalidKeyException"> if the key is invalid. </exception>
        /// <exception cref="SignatureException"> if signing fails. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public SignedObject(Serializable object, PrivateKey signingKey, Signature signingEngine) throws IOException, InvalidKeyException, SignatureException
        public SignedObject(Serializable @object, PrivateKey signingKey, Signature signingEngine)
        {
            // creating a stream pipe-line, from a to b
            ByteArrayOutputStream b = new ByteArrayOutputStream();
            ObjectOutput          a = new ObjectOutputStream(b);

            // write and flush the object content to byte array
            a.WriteObject(@object);
            a.Flush();
            a.Close();
            this.Content = b.ToByteArray();
            b.Close();

            // now sign the encapsulated object
            this.Sign(signingKey, signingEngine);
        }
        /// <summary>Returns the result of applying the parser to arg as a serialized tree.</summary>
        /// <exception cref="System.IO.IOException"/>
        public virtual void HandleTree(string arg, OutputStream outStream)
        {
            Tree tree = Parse(arg, false);

            if (tree == null)
            {
                return;
            }
            log.Info(tree);
            if (tree != null)
            {
                ObjectOutputStream oos = new ObjectOutputStream(outStream);
                oos.WriteObject(tree);
                oos.Flush();
            }
        }
        public static void OutputModel(string fileName, IClassifier <string, string> clf)
        {
            FileOutputStream fo = null;

            try
            {
                fo = new FileOutputStream(fileName);
                ObjectOutputStream so = new ObjectOutputStream(fo);
                so.WriteObject(clf);
                so.Flush();
                so.Close();
            }
            catch (FileNotFoundException e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
            }
            catch (IOException e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
            }
        }
Exemple #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void flush() throws java.io.IOException
            public virtual void Flush()
            {
                base.Flush();
                LocOut.Flush();
            }