WriteInt() public method

Writes an int as four bytes.

32-bit unsigned integer written as four bytes, high-order bytes first.

public WriteInt ( int i ) : void
i int
return void
Example #1
0
 /// <summary>
 /// Writes a codec header, which records both a string to
 /// identify the file and a version number. this header can
 /// be parsed and validated with
 /// <seealso cref="#checkHeader(DataInput, String, int, int) checkHeader()"/>.
 /// <p>
 /// CodecHeader --&gt; Magic,CodecName,Version
 /// <ul>
 ///    <li>Magic --&gt; <seealso cref="DataOutput#writeInt Uint32"/>. this
 ///        identifies the start of the header. It is always {@value #CODEC_MAGIC}.
 ///    <li>CodecName --&gt; <seealso cref="DataOutput#writeString String"/>. this
 ///        is a string to identify this file.
 ///    <li>Version --&gt; <seealso cref="DataOutput#writeInt Uint32"/>. Records
 ///        the version of the file.
 /// </ul>
 /// <p>
 /// Note that the length of a codec header depends only upon the
 /// name of the codec, so this length can be computed at any time
 /// with <seealso cref="#headerLength(String)"/>.
 /// </summary>
 /// <param name="out"> Output stream </param>
 /// <param name="codec"> String to identify this file. It should be simple ASCII,
 ///              less than 128 characters in length. </param>
 /// <param name="version"> Version number </param>
 /// <exception cref="IOException"> If there is an I/O error writing to the underlying medium. </exception>
 public static void WriteHeader(DataOutput @out, string codec, int version)
 {
     BytesRef bytes = new BytesRef(codec);
     if (bytes.Length != codec.Length || bytes.Length >= 128)
     {
         throw new System.ArgumentException("codec must be simple ASCII, less than 128 characters in length [got " + codec + "]");
     }
     @out.WriteInt(CODEC_MAGIC);
     @out.WriteString(codec);
     @out.WriteInt(version);
 }