コード例 #1
0
ファイル: ExceptionContext.cs プロジェクト: 15831944/Essence
        /// <summary>
        /// Deserialize <seealso cref="#msgPatterns"/> and <seealso cref="#msgArguments"/>.
        /// </summary>
        /// <param name="in"> Stream. </param>
        /// <exception cref="IOException"> This should never happen. </exception>
        /// <exception cref="ClassNotFoundException"> This should never happen. </exception>
        private void DeSerializeMessages(ObjectInputStream @in)
        {
            // Step 1.
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int len = in.readInt();
            int len = @in.readInt();

            msgPatterns  = new List <Localizable>(len);
            msgArguments = new List <object[]>(len);
            // Step 2.
            for (int i = 0; i < len; i++)
            {
                // Step 3.
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Localizable pat = (Localizable) in.readObject();
                Localizable pat = (Localizable)@in.readObject();
                msgPatterns.Add(pat);
                // Step 4.
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int aLen = in.readInt();
                int aLen = @in.readInt();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Object[] args = new Object[aLen];
                object[] args = new object[aLen];
                for (int j = 0; j < aLen; j++)
                {
                    // Step 5.
                    args[j] = @in.readObject();
                }
                msgArguments.Add(args);
            }
        }
コード例 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static Object deepCopy(Object paramObject) throws Exception
        public static object deepCopy(object paramObject)
        {
            objectOutputStream = null;
            objectInputStream  = null;
            try
            {
                MemoryStream byteArrayOutputStream = new MemoryStream();
                objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
                objectOutputStream.writeObject(paramObject);
                objectOutputStream.flush();
                MemoryStream byteArrayInputStream = new MemoryStream(byteArrayOutputStream.toByteArray());
                objectInputStream = new ObjectInputStream(byteArrayInputStream);
                return(objectInputStream.readObject());
            }
            catch (Exception exception)
            {
                Console.WriteLine("Exception in ObjectCloner = " + exception);
                throw exception;
            }
            finally
            {
                objectOutputStream.close();
                objectInputStream.close();
            }
        }
コード例 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException
            internal virtual void readObject(ObjectInputStream @in)
            {
                @in.defaultReadObject();
                Type   type = (Type)@in.readObject();
                string name = (string)@in.readObject();

                Type[] args = (Type[])@in.readObject();
                try
                {
                    method = type.getDeclaredMethod(name, args);
                }
                catch (NoSuchMethodException e)
                {
                    throw new IOException(e.Message);
                }
            }
コード例 #4
0
 /// <summary>
 /// クリップボードに格納された文字列を元に,デシリアライズされたオブジェクトを取得します
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 private Object getDeserializedObjectFromText(String s)
 {
     if (s.StartsWith(CLIP_PREFIX))
     {
         int index = s.IndexOf(":");
         index = s.IndexOf(":", index + 1);
         Object ret = null;
         try
         {
             ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decode(str.sub(s, index + 1)));
             ObjectInputStream    ois  = new ObjectInputStream(bais);
             ret = ois.readObject();
         }
         catch (Exception ex)
         {
             ret = null;
             Logger.write(typeof(ClipboardModel) + ".getDeserializedObjectFromText; ex=" + ex + "\n");
         }
         return(ret);
     }
     else
     {
         return(null);
     }
 }
コード例 #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public Object getConfigFileEntryObject(String fileName) throws org.maltparser.core.exception.MaltChainedException
        public virtual object getConfigFileEntryObject(string fileName)
        {
            object @object = null;

            try
            {
                ObjectInputStream input = new ObjectInputStream(getInputStreamFromConfigFileEntry(fileName));
                try
                {
                    @object = input.readObject();
                }
                catch (ClassNotFoundException e)
                {
                    throw new ConfigurationException("Could not load object '" + fileName + "' from mco-file", e);
                }
                catch (Exception e)
                {
                    throw new ConfigurationException("Could not load object '" + fileName + "' from mco-file", e);
                }
                finally
                {
                    input.close();
                }
            }
            catch (IOException e)
            {
                throw new ConfigurationException("Could not load object from '" + fileName + "' in mco-file", e);
            }
            return(@object);
        }
コード例 #6
0
        // package-private for testing
        Module deserialize(string sourcePath)
        {
#if NEVER
            string            cachePath = getCachePath(sourcePath);
            FileInputStream   fis       = null;
            ObjectInputStream ois       = null;
            try {
                fis = new FileInputStream(cachePath);
                ois = new ObjectInputStream(fis);
                return((Module)ois.readObject());
            } catch (Exception e) {
                return(null);
            } finally {
                try {
                    if (ois != null)
                    {
                        ois.close();
                    }
                    else if (fis != null)
                    {
                        fis.close();
                    }
                } catch (Exception e) {
                }
            }
        }
コード例 #7
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Asserts that the object can be serialized and deserialized to an equal form.
 /// </summary>
 /// <param name="base">  the object to be tested </param>
 public static void assertSerialization(object @base)
 {
     assertNotNull(@base);
     try
     {
         using (MemoryStream baos = new MemoryStream())
         {
             using (ObjectOutputStream oos = new ObjectOutputStream(baos))
             {
                 oos.writeObject(@base);
                 oos.close();
                 using (MemoryStream bais = new MemoryStream(baos.toByteArray()))
                 {
                     using (ObjectInputStream ois = new ObjectInputStream(bais))
                     {
                         assertEquals(ois.readObject(), @base);
                     }
                 }
             }
         }
     }
     catch (Exception ex) when(ex is IOException || ex is ClassNotFoundException)
     {
         throw new Exception(ex);
     }
 }
コード例 #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected org.maltparser.ml.lib.FeatureMap loadFeatureMap(java.io.InputStream is) throws org.maltparser.core.exception.MaltChainedException
        protected internal virtual FeatureMap loadFeatureMap(Stream @is)
        {
            FeatureMap map = new FeatureMap();

            try
            {
                ObjectInputStream input = new ObjectInputStream(@is);
                try
                {
                    map = (FeatureMap)input.readObject();
                }
                finally
                {
                    input.close();
                }
            }
            catch (ClassNotFoundException e)
            {
                throw new LibException("Load feature map error", e);
            }
            catch (IOException e)
            {
                throw new LibException("Load feature map error", e);
            }
            return(map);
        }
コード例 #9
0
ファイル: NeuralNetwork.cs プロジェクト: starhash/Neuroph.NET
        /// <summary>
        /// Loads and return s neural network instance from specified file
        /// </summary>
        /// <param name="file"> neural network file </param>
        /// <returns> neural network instance </returns>
        public static NeuralNetwork createFromFile(File file)
        {
            ObjectInputStream oistream = null;

            try {
                if (!file.exists())
                {
                    throw new FileNotFoundException("Cannot find file: " + file);
                }

                oistream = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)));
                NeuralNetwork nnet = (NeuralNetwork)oistream.readObject();
                return(nnet);
            } catch (IOException ioe) {
                throw new NeurophException("Could not read neural network file!", ioe);
            } catch (ClassNotFoundException cnfe) {
                throw new NeurophException("Class not found while trying to read neural network from file!", cnfe);
            } finally {
                if (oistream != null)
                {
                    try {
                        oistream.close();
                    } catch (IOException) {
                    }
                }
            }
        }
コード例 #10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private Object readObject(byte[] data) throws java.io.IOException, ClassNotFoundException
        private object readObject(sbyte[] data)
        {
            Stream            buffer      = new MemoryStream(data);
            ObjectInputStream inputStream = new ObjectInputStream(buffer);
            object            @object     = inputStream.readObject();

            return(@object);
        }
コード例 #11
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public Object receive(Payload payload) throws java.io.IOException, ClassNotFoundException
        public virtual object Receive(Payload payload)
        {
            MemoryStream @in = new MemoryStream(payload.Buf, 0, payload.Len);

            using (ObjectInputStream oin = _objectInputStreamFactory.create(@in))
            {
                return(oin.readObject());
            }
        }
コード例 #12
0
        private static weka.classifiers.functions.SMO loadSMOModel(String name, java.io.File path)
        {
            // weka.classifiers.bayes.HMM .HMMEstimator.packageManagement.Package p=new ;
            weka.classifiers.functions.SMO classifier;
            FileInputStream   fis = new FileInputStream(name);
            ObjectInputStream ois = new ObjectInputStream(fis);

            classifier = (weka.classifiers.functions.SMO)ois.readObject();
            ois.close();

            return(classifier);
        }
コード例 #13
0
        protected internal static string[] readStringMap(ObjectInputStream @in)
        {
            int num = @in.readInt();

            string[] array = new string[num];
            for (int i = 0; i < num; i++)
            {
                string text = (string)@in.readObject();
                array[i] = text;
            }
            return(array);
        }
コード例 #14
0
        private static weka.classifiers.meta.Bagging loadBaggingModel(String name, java.io.File path)
        {
            weka.classifiers.meta.Bagging classifier;

            FileInputStream   fis = new FileInputStream("..\\..\\..\\..\\libs\\models\\" + "models" + name + ".model");
            ObjectInputStream ois = new ObjectInputStream(fis);

            classifier = (weka.classifiers.meta.Bagging)ois.readObject();
            ois.close();

            return(classifier);
        }
コード例 #15
0
        private static weka.classifiers.functions.MultilayerPerceptron loadModel(String name, java.io.File path)
        {
            // weka.classifiers.bayes.HMM .HMMEstimator.packageManagement.Package p=new ;
            weka.classifiers.functions.MultilayerPerceptron classifier;
            FileInputStream   fis = new FileInputStream(Constant.libsPath + "\\models\\" + "models" + name + ".model");
            ObjectInputStream ois = new ObjectInputStream(fis);

            classifier = (weka.classifiers.functions.MultilayerPerceptron)ois.readObject();
            ois.close();

            return(classifier);
        }
コード例 #16
0
        //--------------------------------------------------------------------------------------------------

        /// <summary>
        /// Serializes and deserializes an array using default serialization.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private static MultiCurrencyAmountArray serializedDeserialize(MultiCurrencyAmountArray array) throws Exception
        private static MultiCurrencyAmountArray serializedDeserialize(MultiCurrencyAmountArray array)
        {
            MemoryStream       byteOutputStream   = new MemoryStream();
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteOutputStream);

            objectOutputStream.writeObject(array);
            objectOutputStream.flush();
            MemoryStream      byteInputStream   = new MemoryStream(byteOutputStream.toByteArray());
            ObjectInputStream objectInputStream = new ObjectInputStream(byteInputStream);

            return((MultiCurrencyAmountArray)objectInputStream.readObject());
        }
コード例 #17
0
ファイル: ExceptionContext.cs プロジェクト: 15831944/Essence
        /// <summary>
        /// Deserialize <seealso cref="#context"/>.
        /// </summary>
        /// <param name="in"> Stream. </param>
        /// <exception cref="IOException"> This should never happen. </exception>
        /// <exception cref="ClassNotFoundException"> This should never happen. </exception>
        private void DeSerializeContext(ObjectInputStream @in)
        {
            // Step 1.
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int len = in.readInt();
            int len = @in.readInt();

            context = new Dictionary <string, object>();
            for (int i = 0; i < len; i++)
            {
                // Step 2.
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String key = (String) in.readObject();
                string key = (string)@in.readObject();
                // Step 3.
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Object value = in.readObject();
                object value = @in.readObject();
                context[key] = value;
            }
        }
コード例 #18
0
 public static Robot getRobotFromFile(File file)
 {
     try
     {
         using (ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(new System.IO.FileStream(file, System.IO.FileMode.Open, System.IO.FileAccess.Read))))
         {
             return((Robot)ois.readObject());
         }
     }
     catch (System.Exception e) when(e is ClassNotFoundException || e is IOException)
     {
         throw new DAOException(e);
     }
 }
コード例 #19
0
            public void readExternal(java.io.ObjectInput __p1)
            {
                Page page = CurrentPage;
                ObjectStateFormatter osf         = new ObjectStateFormatter(page);
                ObjectInputStream    inputStream = new ObjectInputStream(__p1);

                if (page.NeedViewStateEncryption || page.EnableViewStateMac)
                {
                    _state = osf.Deserialize((string)inputStream.readObject());
                }
                else
                {
                    _state = osf.Deserialize(inputStream);
                }
            }
コード例 #20
0
 /**
  * Reads one object from the given ObjectInputStream, which is
  * assumed to be a LexicalizedParser.  Throws a ClassCastException
  * if this is not true.  The stream is not closed.
  */
 public static LexicalizedParser loadModel(ObjectInputStream ois)
 {
     try {
         Object o = ois.readObject();
         if (o instanceof LexicalizedParser)
         {
             return((LexicalizedParser)o);
         }
         throw new ClassCastException("Wanted LexicalizedParser, got " +
                                      o.getClass());
     } catch (IOException e) {
         throw new RuntimeIOException(e);
     } catch (ClassNotFoundException e) {
         throw new RuntimeException(e);
     }
 }
コード例 #21
0
        private static ImmutableFst readImmutableFst(ObjectInputStream objectInputStream)
        {
            string[]     isyms        = Fst.readStringMap(objectInputStream);
            string[]     osyms        = Fst.readStringMap(objectInputStream);
            int          num          = objectInputStream.readInt();
            Semiring     semiring     = (Semiring)objectInputStream.readObject();
            int          num2         = objectInputStream.readInt();
            ImmutableFst immutableFst = new ImmutableFst(num2);

            immutableFst.isyms    = isyms;
            immutableFst.osyms    = osyms;
            immutableFst.semiring = semiring;
            for (int i = 0; i < num2; i++)
            {
                int            num3           = objectInputStream.readInt();
                ImmutableState immutableState = new ImmutableState(num3 + 1);
                float          num4           = objectInputStream.readFloat();
                if (num4 == immutableFst.semiring.zero())
                {
                    num4 = immutableFst.semiring.zero();
                }
                else if (num4 == immutableFst.semiring.one())
                {
                    num4 = immutableFst.semiring.one();
                }
                immutableState.setFinalWeight(num4);
                immutableState.id = objectInputStream.readInt();
                immutableFst.states[immutableState.getId()] = immutableState;
            }
            immutableFst.setStart(immutableFst.states[num]);
            num2 = immutableFst.states.Length;
            for (int i = 0; i < num2; i++)
            {
                ImmutableState immutableState2 = immutableFst.states[i];
                for (int j = 0; j < immutableState2.initialNumArcs - 1; j++)
                {
                    Arc arc = new Arc();
                    arc.setIlabel(objectInputStream.readInt());
                    arc.setOlabel(objectInputStream.readInt());
                    arc.setWeight(objectInputStream.readFloat());
                    arc.setNextState(immutableFst.states[objectInputStream.readInt()]);
                    immutableState2.setArc(j, arc);
                }
            }
            return(immutableFst);
        }
コード例 #22
0
        private static Fst readFst(ObjectInputStream objectInputStream)
        {
            string[] array    = Fst.readStringMap(objectInputStream);
            string[] array2   = Fst.readStringMap(objectInputStream);
            int      num      = objectInputStream.readInt();
            Semiring semiring = (Semiring)objectInputStream.readObject();
            int      num2     = objectInputStream.readInt();
            Fst      fst      = new Fst(num2);

            fst.isyms    = array;
            fst.osyms    = array2;
            fst.semiring = semiring;
            for (int i = 0; i < num2; i++)
            {
                int   num3  = objectInputStream.readInt();
                State state = new State(num3 + 1);
                float num4  = objectInputStream.readFloat();
                if (num4 == fst.semiring.zero())
                {
                    num4 = fst.semiring.zero();
                }
                else if (num4 == fst.semiring.one())
                {
                    num4 = fst.semiring.one();
                }
                state.setFinalWeight(num4);
                state.id = objectInputStream.readInt();
                fst.states.add(state);
            }
            fst.setStart((State)fst.states.get(num));
            num2 = fst.getNumStates();
            for (int i = 0; i < num2; i++)
            {
                State state2 = fst.getState(i);
                for (int j = 0; j < state2.initialNumArcs - 1; j++)
                {
                    Arc arc = new Arc();
                    arc.setIlabel(objectInputStream.readInt());
                    arc.setOlabel(objectInputStream.readInt());
                    arc.setWeight(objectInputStream.readFloat());
                    arc.setNextState((State)fst.states.get(objectInputStream.readInt()));
                    state2.addArc(arc);
                }
            }
            return(fst);
        }
コード例 #23
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException
        private void readObject(ObjectInputStream @in)
        {
            @in.defaultReadObject();
            MethodWrapper[] wrappers = (MethodWrapper[])@in.readObject();
            if (wrappers.Length == 0)
            {
                functions = NO_FUNCTIONS;
            }
            else
            {
                functions = new System.Reflection.MethodInfo[wrappers.Length];
                for (int i = 0; i < functions.Length; i++)
                {
                    functions[i] = wrappers[i].method;
                }
            }
        }
コード例 #24
0
 public static object load(string fname)
 {
     object r = null;
     try
     {
         FileInputStream fs = new FileInputStream(fname);
         ObjectInputStream @in = new ObjectInputStream(fs);
         r = @in.readObject();
         @in.close();
         return r;
     }
     catch(Exception ex)
     {
         ex.printStackTrace();
     }
     return r;
 }
コード例 #25
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static MemberIsUnavailable deserialize(byte[] serialized) throws Exception
        private static MemberIsUnavailable Deserialize(sbyte[] serialized)
        {
            ObjectInputStream inputStream = null;

            try
            {
                MemoryStream byteArrayInputStream = new MemoryStream(serialized);
                inputStream = (new ObjectStreamFactory()).create(byteArrayInputStream);
                return(( MemberIsUnavailable )inputStream.readObject());
            }
            finally
            {
                if (inputStream != null)
                {
                    inputStream.close();
                }
            }
        }
コード例 #26
0
ファイル: FaultSkin.cs プロジェクト: Veggie13/ipf
        public static FaultSkin readFromFileSlow(String fileName)
        {
            throw new NotImplementedException();
#if false
            try
            {
                FileInputStream   fis  = new FileInputStream(fileName);
                ObjectInputStream ois  = new ObjectInputStream(fis);
                FaultSkin         skin = (FaultSkin)ois.readObject();
                ois.close();
                return(skin);
            }
            catch (Exception e)
            {
                throw new RuntimeException(e);
            }
#endif
        }
コード例 #27
0
ファイル: DataSet.cs プロジェクト: starhash/Neuroph.NET
        /// <summary>
        /// Loads training set from the specified file
        /// </summary>
        /// <param name="filePath"> training set file </param>
        /// <returns> loded training set </returns>
        public static DataSet load(string filePath)
        {
            ObjectInputStream oistream = null;

            try
            {
                File file = new File(filePath);
                if (!file.exists())
                {
                    throw new FileNotFoundException("Cannot find file: " + filePath);
                }

                oistream = new ObjectInputStream(new FileInputStream(filePath));

                object  obj     = oistream.readObject();
                DataSet dataSet = (DataSet)obj;
                dataSet.FilePath = filePath;

                return(dataSet);
            }
            catch (IOException ioe)
            {
                throw new NeurophException("Error reading file!", ioe);
            }
            catch (ClassNotFoundException ex)
            {
                throw new NeurophException("Class not found while trying to read DataSet object from the stream!", ex);
            }
            finally
            {
                if (oistream != null)
                {
                    try
                    {
                        oistream.close();
                    }
                    catch (IOException)
                    {
                    }
                }
            }
        }
コード例 #28
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public Desktop.common.nomitech.common.base.BaseTableList resourcesFromSer(java.io.File paramFile) throws Exception
        public virtual BaseTableList resourcesFromSer(File paramFile)
        {
            FileStream          fileInputStream     = new FileStream(paramFile, FileMode.Open, FileAccess.Read);
            BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
            ObjectInputStream   objectInputStream   = new ObjectInputStream(bufferedInputStream);
            BaseTableList       baseTableList       = null;

            try
            {
                baseTableList = (BaseTableList)objectInputStream.readObject();
            }
            catch (Exception exception)
            {
                objectInputStream.close();
                Console.WriteLine(exception.ToString());
                Console.Write(exception.StackTrace);
                throw exception;
            }
            objectInputStream.close();
            return(baseTableList);
        }
コード例 #29
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public Desktop.common.nomitech.common.db.project.ProjectTemplateTable projectTemplateFromSer(java.io.File paramFile) throws Exception
        public virtual ProjectTemplateTable projectTemplateFromSer(File paramFile)
        {
            FileStream           fileInputStream      = new FileStream(paramFile, FileMode.Open, FileAccess.Read);
            BufferedInputStream  bufferedInputStream  = new BufferedInputStream(fileInputStream);
            ObjectInputStream    objectInputStream    = new ObjectInputStream(bufferedInputStream);
            ProjectTemplateTable projectTemplateTable = null;

            try
            {
                projectTemplateTable = (ProjectTemplateTable)objectInputStream.readObject();
            }
            catch (Exception exception)
            {
                objectInputStream.close();
                Console.WriteLine(exception.ToString());
                Console.Write(exception.StackTrace);
                throw exception;
            }
            objectInputStream.close();
            return(projectTemplateTable);
        }
コード例 #30
0
        public static void assertObjectValueSerializedJava(ObjectValue typedValue, object value)
        {
            assertEquals(Variables.SerializationDataFormats.JAVA.Name, typedValue.SerializationDataFormat);

            try
            {
                // validate this is the base 64 encoded string representation of the serialized value of the java object
                string            valueSerialized   = typedValue.ValueSerialized;
                sbyte[]           decodedObject     = Base64.decodeBase64(valueSerialized.GetBytes(Charset.forName("UTF-8")));
                ObjectInputStream objectInputStream = new ObjectInputStream(new MemoryStream(decodedObject));
                assertEquals(value, objectInputStream.readObject());
            }
            catch (IOException e)
            {
                throw new Exception(e);
            }
            catch (ClassNotFoundException e)
            {
                throw new Exception(e);
            }
        }
コード例 #31
0
        private void ReadAndThrowFailureResponse()
        {
            Exception cause;

            try
            {
                using (ObjectInputStream input = new ObjectInputStream(AsInputStream()))
                {
                    cause = ( Exception )input.readObject();
                }
            }
            catch (Exception e)
            {
                // Note: this is due to a problem with the streaming of exceptions, the ChunkingChannelBuffer will almost
                // always sends exceptions back as two chunks, the first one empty and the second with the exception.
                // We hit this when we try to read the exception of the first one, and in reading it hit the second
                // chunk with the "real" exception. This should be revisited to 1) clear up the chunking and 2) handle
                // serialized exceptions spanning multiple chunks.
                if (e is Exception)
                {
                    throw ( Exception )e;
                }
                if (e is Exception)
                {
                    throw ( Exception )e;
                }

                throw new ComException(e);
            }

            if (cause is Exception)
            {
                throw ( Exception )cause;
            }
            if (cause is Exception)
            {
                throw ( Exception )cause;
            }
            throw new ComException(cause);
        }
コード例 #32
0
ファイル: AstCache.cs プロジェクト: uxmal/pytocs
        // package-private for testing
        Module deserialize(string sourcePath)
        {
#if NEVER
        string cachePath = getCachePath(sourcePath);
        FileInputStream fis = null;
        ObjectInputStream ois = null;
        try {
            fis = new FileInputStream(cachePath);
            ois = new ObjectInputStream(fis);
            return (Module) ois.readObject();
        } catch (Exception e) {
            return null;
        } finally {
            try {
                if (ois != null) {
                    ois.close();
                } else if (fis != null) {
                    fis.close();
                }
            } catch (Exception e) {

            }
        }
    }
コード例 #33
0
ファイル: LexicalizedParser.cs プロジェクト: gblosser/OpenNlp
 /**
  * Reads one object from the given ObjectInputStream, which is
  * assumed to be a LexicalizedParser.  Throws a ClassCastException
  * if this is not true.  The stream is not closed.
  */
 public static LexicalizedParser loadModel(ObjectInputStream ois) {
   try {
     Object o = ois.readObject();
     if (o instanceof LexicalizedParser) {
       return (LexicalizedParser) o;
     }
     throw new ClassCastException("Wanted LexicalizedParser, got " +
                                  o.getClass());
   } catch (IOException e) {
     throw new RuntimeIOException(e);
   } catch (ClassNotFoundException e) {
     throw new RuntimeException(e);
   }
 }