Lucene.Net  3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
Test.cs
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 using System;
19 
20 namespace Lucene.Net.Demo.Html
21 {
22 
23  class Test
24  {
25  [STAThread]
26  public static void Main(System.String[] argv)
27  {
28  if ("-dir".Equals(argv[0]))
29  {
30  System.String[] files = System.IO.Directory.GetFileSystemEntries(new System.IO.FileInfo(argv[1]).FullName);
31  System.Array.Sort(files);
32  for (int i = 0; i < files.Length; i++)
33  {
34  System.Console.Error.WriteLine(files[i]);
35  System.IO.FileInfo file = new System.IO.FileInfo(System.IO.Path.Combine(argv[1], files[i]));
36  Parse(file);
37  }
38  }
39  else
40  Parse(new System.IO.FileInfo(argv[0]));
41  }
42 
43  public static void Parse(System.IO.FileInfo file)
44  {
45  System.IO.FileStream fis = null;
46  try
47  {
48  fis = new System.IO.FileStream(file.FullName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
49  HTMLParser parser = new HTMLParser(fis);
50  System.Console.Out.WriteLine("Title: " + Entities.Encode(parser.GetTitle()));
51  System.Console.Out.WriteLine("Summary: " + Entities.Encode(parser.GetSummary()));
52  System.Console.Out.WriteLine("Content:");
53  System.IO.StreamReader reader = new System.IO.StreamReader(parser.GetReader().BaseStream, parser.GetReader().CurrentEncoding);
54  for (System.String l = reader.ReadLine(); l != null; l = reader.ReadLine())
55  System.Console.Out.WriteLine(l);
56  }
57  finally
58  {
59  if (fis != null)
60  fis.Close();
61  }
62  }
63  }
64 }