org.apache.lucene.analysis.miscellaneous.PatternAnalyzer.ToString C# (CSharp) Method

ToString() private static method

Reads until end-of-stream and returns all read chars, finally closes the stream.
if an I/O error occurs while reading the stream
private static ToString ( Reader input ) : string
input Reader the input stream
return string
	  private static string ToString(Reader input)
	  {
		if (input is FastStringReader) // fast path
		{
		  return ((FastStringReader) input).String;
		}

		try
		{
		  int len = 256;
		  char[] buffer = new char[len];
		  char[] output = new char[len];

		  len = 0;
		  int n;
		  while ((n = input.read(buffer)) >= 0)
		  {
			if (len + n > output.Length) // grow capacity
			{
			  char[] tmp = new char[Math.Max(output.Length << 1, len + n)];
			  Array.Copy(output, 0, tmp, 0, len);
			  Array.Copy(buffer, 0, tmp, len, n);
			  buffer = output; // use larger buffer for future larger bulk reads
			  output = tmp;
			}
			else
			{
			  Array.Copy(buffer, 0, output, len, n);
			}
			len += n;
		  }

		  return new string(output, 0, len);
		}
		finally
		{
		  input.close();
		}
	  }

Usage Example

示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void reset() throws java.io.IOException
            public override void reset()
            {
                base.reset();
                this.str         = PatternAnalyzer.ToString(input);
                this.matcher     = pattern.matcher(this.str);
                this.pos         = 0;
                this.initialized = true;
            }
All Usage Examples Of org.apache.lucene.analysis.miscellaneous.PatternAnalyzer::ToString