private void Close()
 {
     if (_OwnStream && _Reader != null)
     {
         _Reader.Close();
         _Reader.Dispose();
     }
     _Reader    = null;
     _OwnStream = false;
 }
示例#2
0
        public static Models.Project Read(string filename)
        {
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(filename);
            string             name     = fileInfo.Name.Substring(0, fileInfo.Name.Length - fileInfo.Extension.Length);

            System.IO.TextReader reader  = System.IO.File.OpenText(filename);
            Models.Project       project = Read(name, reader);
            reader.Close();
            return(project);
        }
        /// <summary> Closes the input stream.</summary>
        public void  Yyclose()
        {
            zzAtEOF   = true;           /* indicate end of file */
            zzEndRead = zzStartRead;    /* invalidate buffer    */

            if (zzReader != null)
            {
                zzReader.Close();
            }
        }
示例#4
0
 /// <summary>By default, closes the input Reader. </summary>
 public override void  Close()
 {
     if (input != null)
     {
         input.Close();
         // LUCENE-2387: don't hold onto Reader after close, so
         // GC can reclaim
         input = null;
     }
 }
示例#5
0
 public void  Done()
 {
     try
     {
         input.Close();
     }
     catch (System.IO.IOException e)
     {
         System.Console.Error.WriteLine("Caught: " + e + "; ignoring.");
     }
 }
示例#6
0
        public static bool Is2005(string path)
        {
            System.IO.TextReader reader = System.IO.File.OpenText(path);
            string line = reader.ReadLine();

            while (line.Length == 0)
            {
                reader.ReadLine();
            }
            reader.Close();
            return(line.Trim().Equals("Microsoft Visual Studio Solution File, Format Version 9.00"));
        }
示例#7
0
        internal void ReadUnlockFile(string filePath)
        {
            try
            {
                if (System.IO.File.Exists(filePath))
                {
                    System.IO.TextReader tr = System.IO.File.OpenText(filePath);

                    bool   unlocked = false;
                    string region   = string.Empty;
                    string line     = string.Empty;

                    while (null != (line = tr.ReadLine()))
                    {
                        string[] la = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);

                        /* True		<tab>	Oceania East */
                        if (la.Length == 2)
                        {
                            unlocked = bool.Parse(la[0].Trim());
                            region   = la[1].Trim();

                            bool found = false;

                            foreach (var inner in Configuration.UnlockedList)
                            {
                                if (region == inner.Region)
                                {
                                    found = true;
                                }
                            }

                            if (!found)
                            {
                                Configuration.UnlockedList.Add(new UnlockedData()
                                {
                                    Region = region, Unlocked = unlocked
                                });
                            }
                        }
                    }

                    tr.Close();
                    tr.Dispose();
                }
            }
            catch (Exception exc)
            {
                Exception c = exc;                 // to remove compiler warnings
                c.Source = "Composer";
            }
        }
示例#8
0
        public void Build(string filename, string configuration)
        {
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(filename);
            string             name     = fileInfo.Name.Substring(0, fileInfo.Name.ToLower().LastIndexOf(".sln"));

            System.IO.TextReader reader   = fileInfo.OpenText();
            Models.Solution      solution = SolutionReader.Read(filename, reader);
            reader.Close();

            string projectFolder = LastLeft(filename, System.IO.Path.DirectorySeparatorChar.ToString());

            this.Build(solution, configuration, projectFolder, String.Empty);
        }
示例#9
0
        public void Build(string filename, string configuration, ProjectBuildTracker projectBuildTracker)
        {
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(filename);
            string             name     = fileInfo.Name.Substring(0, fileInfo.Name.ToLower().LastIndexOf(".csproj"));

            System.IO.TextReader reader  = fileInfo.OpenText();
            Models.Project       project = ProjectReader.Read(name, reader);
            reader.Close();

            string projectFolder = LastLeft(filename, System.IO.Path.DirectorySeparatorChar.ToString());

            this.Build(project, configuration, projectFolder, projectBuildTracker);
        }
示例#10
0
        static void Main(string[] args)
        {
            System.IO.TextReader  reader            = System.IO.File.OpenText(args[0]);
            Ice.InstructionStream instructionStream = new Ice.InstructionStream(new Ice.TextReader(reader));

            Ice.Machines.RegisterMachine machine = new Ice.Machines.RegisterMachine(8);
            machine.InstructionStream = instructionStream;
            machine.Run(instructionStream);

            reader.Close();

            System.Console.ReadLine();
        }
示例#11
0
        static StackObject *Close_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.IO.TextReader instance_of_this_method = (System.IO.TextReader) typeof(System.IO.TextReader).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.Close();

            return(__ret);
        }
示例#12
0
        // TODO: Text reading
        // TODO: Object serialization
        // TODO: Object deserialization

        public override void Close()
        {
            if (TextWriter != null)
            {
                TextWriter.Flush();
                TextWriter.Close();
                TextWriter = null;
            }

            if (TextReader != null)
            {
                TextReader.Close();
                TextWriter = null;
            }
        }
示例#13
0
        public static Phonebook loadFromFile(System.IO.TextReader textIn, Phonebook contacts)
        {
            int numberOfContacts = int.Parse(textIn.ReadLine());

            for (int i = 0; i < numberOfContacts; i++)
            {
                contacts.addContact(Contact.loadFromFile(textIn));
            }

            if (textIn != null)
            {
                textIn.Close();
            }

            return(contacts);
        }
示例#14
0
        public static bool ConvertList(string fileName)
        {
            List <ATSCTuning> _atscChannels = new List <ATSCTuning>();
            string            line;

            string[]             tpdata;
            System.IO.TextReader tin = System.IO.File.OpenText(fileName);
            do
            {
                line = tin.ReadLine();
                if (line != null)
                {
                    if (line.Length > 0)
                    {
                        if (line.StartsWith(";"))
                        {
                            continue;
                        }
                        tpdata = line.Split(new char[] { ',' });
                        if (tpdata.Length != 1)
                        {
                            tpdata = line.Split(new char[] { ';' });
                        }
                        if (tpdata.Length == 1)
                        {
                            try
                            {
                                _atscChannels.Add(new ATSCTuning(Int32.Parse(tpdata[0])));
                            }
                            catch
                            {
                            }
                        }
                    }
                }
            } while (!(line == null));
            tin.Close();

            String newPath = String.Format("{0}\\atsc\\{1}.xml", System.IO.Path.GetDirectoryName(fileName), System.IO.Path.GetFileNameWithoutExtension(fileName));

            System.IO.TextWriter parFileXML    = System.IO.File.CreateText(newPath);
            XmlSerializer        xmlSerializer = new XmlSerializer(typeof(List <ATSCTuning>));

            xmlSerializer.Serialize(parFileXML, _atscChannels);
            parFileXML.Close();
            return(true);
        }
示例#15
0
 private void CheckForUpdateWorker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
 {
     if (e.Result == true)
     {
         System.IO.TextReader textreader = System.IO.File.OpenText(Document.Editor.My.Computer.FileSystem.SpecialDirectories.Temp + "\\Semagsoft\\DocumentEditor\\updatechecker.ini");
         string version       = textreader.ReadLine();
         int    versionyear   = Convert.ToInt16(version.Substring(0, 4));
         int    versionnumber = Convert.ToInt16(version.Substring(5));
         if (versionyear >= Document.Editor.My.Application.Info.Version.Major && versionnumber > Document.Editor.My.Application.Info.Version.Minor)
         {
             Collection whatsnew = new Collection();
             string     line     = null;
             do
             {
                 line = textreader.ReadLine();
                 if (line != null)
                 {
                     whatsnew.Add(line.ToString());
                 }
             } while (!(line == null));
             textreader.Close();
             UpdateText.Text               = "An update(" + version + ") was found, do you want to apply it?";
             ProgressBox.Visibility        = System.Windows.Visibility.Collapsed;
             ApplyUpdateButton.Visibility  = System.Windows.Visibility.Visible;
             CancelUpdateButton.Visibility = System.Windows.Visibility.Visible;
             WhatsNewTextBox.Clear();
             foreach (string s in whatsnew)
             {
                 WhatsNewTextBox.AppendText(s + Constants.vbNewLine);
             }
             WhatsNewTextBlock.Visibility = System.Windows.Visibility.Visible;
             WhatsNewTextBox.Visibility   = System.Windows.Visibility.Visible;
         }
         else
         {
             MessageBoxDialog m = new MessageBoxDialog("Document.Editor is already up to date", "Up To Date", null, null);
             m.MessageImage.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Common/info32.png"));
             m.Owner = this;
             m.ShowDialog();
             UpdateBox.Visibility     = System.Windows.Visibility.Hidden;
             AppLogo.Visibility       = System.Windows.Visibility.Visible;
             LicenseButton.Visibility = System.Windows.Visibility.Visible;
             OKButton.Visibility      = System.Windows.Visibility.Visible;
             UpdateButton.Visibility  = System.Windows.Visibility.Visible;
         }
     }
 }
示例#16
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string[] meslekler = { "mühendis",  "Öğretmen",   "Öğrenci",         "İşçi",
                                   "Programcı", "Muhasabeci", "Satış Pazarlama",
                                   "Ekonomist", "Müfettiş",   "Avukat" };
            // bu meslekler comboBox (açılır liste kutusu) kontrolüne ekleniyor
            comboBox_meslek.Items.AddRange(meslekler);

            string[] birim = { "Satış",         "Eğitim",  "Pazarlama", "Reklam",  "Üretim", "Muhasebe",
                               "Teknik Destek", "Yazılım", "Network",   "Yönetim", "Çağrı Merkezi" };

            //bu birimler comboBox (açılır liste kutusu) kontrolüne ekleniyor
            comboBox_Calislian_birim.Items.AddRange(birim);


            //kaydedilmiş dosyayı aç
            try
            {
                //dosyayı aç
                System.IO.TextReader dosya_ac = System.IO.File.OpenText("C:\\personel_kayit.dat");
                string satir = "";

                //dosyadaki bilgileri listBox kontrollerine ekle
                while ((satir = dosya_ac.ReadLine()) != null)
                {
                    listBox1.Items.Add(satir);

                    satir = dosya_ac.ReadLine();
                    listBox2.Items.Add(satir);

                    satir = dosya_ac.ReadLine();
                    listBox3.Items.Add(satir);
                }
                //dosyayı kapat
                dosya_ac.Close();
            }
            catch
            {
                /*program ilk çalıştırıldığında önceden kaydedilmiş dosya olmayacağı için
                 * try bloğu kırılarak catch bloğu devreye girecek ancak burada herhangi
                 * bir işlem yapılmayacak*/
            }

            label6.Text = listBox1.Items.Count.ToString();
            label8.Text = (listBox1.SelectedIndex + 1).ToString();
        }
 protected virtual void CloseConnection()
 {
     try
     {
         @in.Close();
         @in = null;
         @out.Close();
         @out = null;
         channel.Close();
         channel = null;
     }
     catch (Exception e)
     {
         Console.Error.WriteLine(e);
         ExceptionExtensions.PrintStackTrace(e, Console.Error);
     }
     finally
     {
         if (@in != null)
         {
             try
             {
                 @in.Close();
             }
             catch (IOException ioe)
             {
                 Console.Error.WriteLine(ioe);
             }
         }
         if (@out != null)
         {
             @out.Close();
         }
         if (channel != null)
         {
             try
             {
                 channel.Close();
             }
             catch (IOException ioe)
             {
                 Console.Error.WriteLine(ioe);
             }
         }
     }
 }
        /// <summary>
        /// The main unit of work of a Source component, populates the pipeline buffer with data.
        /// </summary>
        /// <param name="outputs"></param>
        /// <param name="outputIDs"></param>
        /// <param name="buffers"></param>
        public override void PrimeOutput(int outputs, int[] outputIDs, PipelineBuffer[] buffers)
        {
            try
            {
                Regex rx    = new Regex(ComponentMetaData.CustomPropertyCollection[s_RegExpPropName].Value.ToString());
                Match match = null;

                using (System.IO.TextReader reader = System.IO.File.OpenText(ComponentMetaData.CustomPropertyCollection[s_InputFilePathNamePropName].Value.ToString()))
                {
                    string crtLine = reader.ReadLine();

                    while (null != crtLine)
                    {
                        match = rx.Match(crtLine);
                        if (match.Success)
                        {
                            // split the text based on the groups in the regular expression and send it to the matching output
                            buffers[0].AddRow();
                            for (int nIdx = 0; nIdx < buffers[0].ColumnCount; nIdx++)
                            {
                                buffers[0].SetString(nIdx, match.Groups[nIdx].Value);
                            }
                        }
                        else
                        {
                            // direct the text to the non-matching output
                            buffers[1].AddRow();
                            buffers[1].SetString(0, crtLine);
                        }
                        crtLine = reader.ReadLine();
                    }

                    reader.Close();
                }

                // mark the pipeline buffers (the matching and non matching ones) as completed.
                buffers[0].SetEndOfRowset();
                buffers[1].SetEndOfRowset();
            }
            catch (Exception ex)
            {
                bool cancel;
                ComponentMetaData.FireError(HResults.DTS_E_PRIMEOUTPUTFAILED, null, ex.Message, null, 0, out cancel);
            }
        }
示例#19
0
        /*
         * Lee desde los archivos todas las instrucciones para luego enviarlas al simulador.
         */
        private void BotonIniciarSimulacion_Click(object sender, EventArgs e)
        {
            //Deshabilitar botones para no entorpecer la interfaz durante la simulación (TODO agregar botón para detenerla)
            BotonNuevaSimulacion.Enabled   = false;
            BotonAgregarArchivo.Enabled    = false;
            BotonIniciarSimulacion.Enabled = false;
            panelProcesadores.Visible      = true; //también hace este panel visible para ver los programas correr
            panelMemoria.Visible           = true; //también hace este panel visible para ver los programas correr

            //Lee todas las instrucciones y las guarda en una lista
            List <int>    instrucciones         = new List <int>(); //arreglo general que almacenará todas las instrucciones leídas
            List <int>    iniciosProgramas      = new List <int>(); //arreglo pequeño que almacena los índices en el anterior donde inicia cada programa
            List <string> nombresProgramas      = new List <string>();
            String        instruccionIndividual = "";               //usada para iterar por las líneas de los archivos

            foreach (String path in pathsArchivos)
            {
                nombresProgramas.Add(path.Substring(path.LastIndexOf('\\') + 1));
                iniciosProgramas.Add(instrucciones.Count);
                System.IO.TextReader lector = System.IO.File.OpenText(path); //abre el archivo para Leer sus líneas una por una
                while ((instruccionIndividual = lector.ReadLine()) != null)
                {
                    string[] partes = System.Text.RegularExpressions.Regex.Split(instruccionIndividual.Trim(), @"\s+");
                    if (partes.Length == 4)
                    {
                        for (short i = 0; i < 4; ++i)
                        {
                            instrucciones.Add(int.Parse(partes[i])); //agrega cada número entero al arreglo
                        }
                    }
                }
                lector.Close();
                cantidadProcesadores = (iniciosProgramas.Count > 2 ? 3 : iniciosProgramas.Count); //para no accesar grids inexistentes
            }

            //Enviar parámetros al simulador e iniciar la simulación
            Simulador simulador      = new Simulador(instrucciones, iniciosProgramas, nombresProgramas, this);
            Thread    hiloSimulacion = new Thread(simulador.EjecutarSimulacion);

            hiloSimulacion.Start();

            crearTuplasMemoriaCompartida(); //de una vez iniciarlizar las tuplas de la memoria compartida

            // NO hacer join al hiloSimulacion porque sino se detienen los eventos de la interfaz grafica
        }
示例#20
0
 public virtual void Load(TextReader r, int size, int readChunkSize) {
     if (r == null) {
         return;
     }
     if (size <= 0) {
         size = InitialBufferSize;
     }
     if (readChunkSize <= 0) {
         readChunkSize = ReadBufferSize;
     }
     // System.out.println("load "+size+" in chunks of "+readChunkSize);
     try {
         data = r.ReadToEnd().ToCharArray();
         base.n = data.Length;
     } finally {
         r.Close();
     }
 }
示例#21
0
文件: 17.cs 项目: qifanyyy/CLCDSA
        static void Main(string[] args)
        {
            System.IO.TextReader TR = null;
            System.IO.TextWriter TW = null;
            try
            {
                switch (args[0].ToUpper())
                {
                case "TEST":
                    TR = System.IO.File.OpenText("../../A-test.in");
                    TW = System.IO.File.CreateText("../../A-test.out");
                    break;

                case "SMALL":
                    TR = System.IO.File.OpenText("../../A-small.in");
                    TW = System.IO.File.CreateText("../../A-small.out");
                    break;

                case "LARGE":
                    TR = System.IO.File.OpenText("../../A-large.in");
                    TW = System.IO.File.CreateText("../../A-large.out");
                    break;

                default:
                    return;
                }
            }
            catch
            {
                TR = System.IO.File.OpenText("../../A-test.in");
                //return;
            }
            int NumCases = System.Convert.ToInt32(TR.ReadLine());

            for (int i = 0; i < NumCases; i++)
            {
                RunCase(i, TR, TW);
            }
            TR.Close();
            if (TW != null)
            {
                TW.Close();
            }
        }
示例#22
0
        /// <summary>
        /// Loads and buffers the contents of the specified reader to be
        /// used as this ANTLRReaderStream's source
        /// </summary>
        public virtual void Load(TextReader reader, int size, int readChunkSize)
        {
            if (reader == null)
            {
                return;
            }
            if (size <= 0)
            {
                size = INITIAL_BUFFER_SIZE;
            }
            if (readChunkSize <= 0)
            {
                readChunkSize = READ_BUFFER_SIZE;
            }

            try
            {
                // alloc initial buffer size.
                data = new char[size];
                // read all the data in chunks of readChunkSize
                int numRead = 0;
                int p       = 0;
                do
                {
                    if (p + readChunkSize > data.Length)
                    {                                               // overflow?
                        char[] newdata = new char[data.Length * 2]; // resize
                        Array.Copy(data, 0, newdata, 0, data.Length);
                        data = newdata;
                    }
                    numRead = reader.Read(data, p, readChunkSize);
                    p      += numRead;
                } while (numRead != 0);                 // while not EOF
                // set the actual size of the data available;
                // EOF subtracted one above in p+=numRead; add one back
                //n = p + 1;
                n = p;
            }
            finally
            {
                reader.Close();
            }
        }
示例#23
0
        public void Load()
        {
            lock (this)
            {
                if (toonName == null)
                {
                    return;
                }
                dic = new Dictionary <string, string>();

                // Load from file
                PPather.WriteLine("Loading toon data...");
                try
                {
                    string filename        = "PPather\\ToonInfo\\" + toonName + ".txt";
                    System.IO.TextReader s = System.IO.File.OpenText(filename);

                    int    nr = 0;
                    string line;
                    while ((line = s.ReadLine()) != null)
                    {
                        char[]   splitter = { '|' };
                        string[] st       = line.Split(splitter);
                        if (st.Length == 2)
                        {
                            string key = st[0];
                            string val = st[1];
                            Set(key, val);
                            nr++;
                        }
                    }
                    PPather.WriteLine("Loaded " + nr + " toon state data");

                    s.Close();
                }
                catch (Exception)
                {
                    PPather.WriteLine("!Warning:Failed reading toon state data");
                }
                changed = false;
            }
        }
示例#24
0
        public void Load()
        {
            lock (this)
            {
                if (this.toonName == null)
                {
                    return;
                }
                this.dic = new Dictionary <string, string>();

                // Load from file
                Logger.Log("Loading toon data...");
                try
                {
                    string filename        = "Plugins\\PPather\\ToonInfo\\" + this.toonName + ".txt";
                    System.IO.TextReader s = System.IO.File.OpenText(filename);

                    int    nr = 0;
                    string line;
                    while ((line = s.ReadLine()) != null)
                    {
                        char[]   splitter = { '|' };
                        string[] st       = line.Split(splitter);
                        if (st.Length == 2)
                        {
                            string key = st[0];
                            string val = st[1];
                            this.Set(key, val);
                            nr++;
                        }
                    }
                    Logger.Log("Loaded " + nr + " toon state data");

                    s.Close();
                }
                catch (Exception)
                {
                    Logger.Log("No toon data to read yet, but no worries :)");
                }
                this.changed = false;
            }
        }
示例#25
0
        protected override void Dispose(bool disposing)
        {
            if (isDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (input != null)
                {
                    input.Close();
                }
            }

            // LUCENE-2387: don't hold onto Reader after close, so
            // GC can reclaim
            input      = null;
            isDisposed = true;
        }
示例#26
0
        public void Load()
        {
            lock (this)
            {
                if (continent == null)
                {
                    return;
                }
                NPCs = new Dictionary <string, NPC>(StringComparer.InvariantCultureIgnoreCase);
                // Load from file
                try
                {
                    string filename        = "PPather\\NPCInfo\\" + continent + "_" + myFaction + ".txt";
                    System.IO.TextReader s = System.IO.File.OpenText(filename);

                    int    nr = 0;
                    string line;
                    while ((line = s.ReadLine()) != null)
                    {
                        NPC n = new NPC();
                        if (n.FromString(line))
                        {
                            if (!NPCs.ContainsKey(n.name))
                            {
                                NPCs.Add(n.name, n);
                                nr++;
                            }
                        }
                    }
                    PPather.WriteLine("Loaded " + nr + " NPCs");

                    s.Close();
                }
                catch (Exception)
                {
                    //PPather.WriteLine("Exception reading NPC data: " + e);
                    PPather.WriteLine("!Warning:Failed to load NPC data");
                }
                changed = false;
            }
        }
示例#27
0
        internal void ReadCollectedFile(string filePath)
        {
            try
            {
                if (System.IO.File.Exists(filePath))
                {
                    System.IO.TextReader tr = System.IO.File.OpenText(filePath);

                    int    collected = 0;
                    string city      = string.Empty;
                    string line      = string.Empty;

                    while (null != (line = tr.ReadLine()))
                    {
                        string[] la = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);

                        /* 25	Lodwar, KE */
                        if (la.Length == 2)
                        {
                            collected = int.Parse(la[0].Trim());
                            city      = la[1].Trim();

                            foreach (var item in Configuration.ResourceList)
                            {
                                if (item.City == city)
                                {
                                    item.Collected = collected;
                                }
                            }
                        }
                    }

                    tr.Close();
                    tr.Dispose();
                }
            }
            catch (Exception exc)
            {
                exc.Source = "Composer";                 // to remove compiler warnings
            }
        }
示例#28
0
        public void Load(string path)
        {
            m_configPath = path;

            try
            {
                System.IO.TextReader tr = System.IO.File.OpenText(path);
                string line;
                bool   parsing = true;

                while ((line = tr.ReadLine()) != null)
                {
                    line = line.Trim();

                    if (line.StartsWith("/*"))
                    {
                        parsing = false;
                    }
                    else
                    if (line.StartsWith("*/"))
                    {
                        parsing = true;
                    }
                    else
                    if (parsing && line.Length > 0 && !line.StartsWith("//"))
                    {
                        string[] split = line.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                        if (split.Length == 2)
                        {
                            m_values[split[0].Trim().ToLower()] = split[1].Trim();
                        }
                    }
                }

                tr.Close();
            }
            catch (System.Exception e)
            {
                Console.WriteLine("Failed to load config file {0} - {1}", path, e.Message);
            }
        }
示例#29
0
 /// <summary> Reads lines from a Reader and adds every line as an entry to a HashSet (omitting
 /// leading and trailing whitespace). Every line of the Reader should contain only
 /// one word. The words need to be in lowercase if you make use of an
 /// Analyzer which uses LowerCaseFilter (like StandardAnalyzer).
 ///
 /// </summary>
 /// <param name="reader">Reader containing the wordlist
 /// </param>
 /// <returns> A HashSet with the reader's words
 /// </returns>
 public static System.Collections.Hashtable GetWordSet(System.IO.TextReader reader)
 {
     System.Collections.Hashtable result = new System.Collections.Hashtable();
     System.IO.TextReader         br     = null;
     try
     {
         System.String word = null;
         while ((word = reader.ReadLine()) != null)
         {
             SupportClass.CollectionsHelper.Add(result, word.Trim());
         }
     }
     finally
     {
         if (br != null)
         {
             br.Close();
         }
     }
     return(result);
 }
示例#30
0
 static void LoadText(System.IO.TextReader Input_S)
 {
     try
     {
         int listcount = int.Parse(Input_S.ReadLine());
         for (int c = 1; c <= listcount; c++) //need to do things here <------------------ VERY IMPORTANT
         {
         }
     }
     catch (Exception e)
     {
         throw e;
     }
     finally
     {
         if (Input_S != null)
         {
             Input_S.Close();
         }
     }
 }
示例#31
0
        public static string ReadToHtml(string htmlPath, System.Collections.Hashtable htReplace)
        {
            try
            {
                System.IO.TextReader reader = System.IO.File.OpenText(AppDomain.CurrentDomain.BaseDirectory + htmlPath);
                string text = reader.ReadToEnd();
                reader.Close();
                reader.Dispose();

                System.Collections.IDictionaryEnumerator ie = htReplace.GetEnumerator();
                while (ie.MoveNext())
                {
                    text = text.Replace(ie.Key.ToString(), ie.Value.ToString());
                }
                return(text);
            }
            catch (Exception)
            {
                return("");
            }
        }
        protected virtual void CloseConnection()
        {
            try
            {
                @in.Close();
                @in = null;
                @out.Close();
                @out = null;
                channel.Close();
                channel = null;
            }
            catch ( Exception e )
            {
                Console.Error.WriteLine( e );
                e.PrintStackTrace( Console.Error );
            }
            finally
            {
                if ( @in != null )
                {
                    try
                    {
                        @in.Close();
                    }
                    catch ( IOException ioe )
                    {
                        Console.Error.WriteLine( ioe );
                    }
                }
                if ( @out != null )
                {
                    @out.Close();
                }
                if ( channel != null )
                {
                    try
                    {
                        channel.Close();
                    }
                    catch ( IOException ioe )
                    {
                        Console.Error.WriteLine( ioe );
                    }
                }
            }

        }
示例#33
0
		/// <summary>
		/// Loads and buffers the contents of the specified reader to be 
		/// used as this ANTLRReaderStream's source
		/// </summary>
		public virtual void Load(TextReader reader, int size, int readChunkSize)
		{
			if (reader == null)
			{
				return;
			}
			if (size <= 0)
			{
				size = INITIAL_BUFFER_SIZE;
			}
			if (readChunkSize <= 0)
			{
				readChunkSize = READ_BUFFER_SIZE;
			}

			try
			{
				// alloc initial buffer size.
				data = new char[size];
				// read all the data in chunks of readChunkSize
				int numRead = 0;
				int p = 0;
				do
				{
					if (p + readChunkSize > data.Length)
					{ // overflow?
						char[] newdata = new char[data.Length * 2]; // resize
						Array.Copy(data, 0, newdata, 0, data.Length);
						data = newdata;
					}
					numRead = reader.Read(data, p, readChunkSize);
					p += numRead;
				} while (numRead != 0); // while not EOF
				// set the actual size of the data available;
				// EOF subtracted one above in p+=numRead; add one back
				//n = p + 1;
				n = p;
			}
			finally
			{
				reader.Close();
			}
		}