当前位置: 首页>>代码示例>>C#>>正文


C# OutputStream.Write方法代码示例

本文整理汇总了C#中Sharpen.OutputStream.Write方法的典型用法代码示例。如果您正苦于以下问题:C# OutputStream.Write方法的具体用法?C# OutputStream.Write怎么用?C# OutputStream.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sharpen.OutputStream的用法示例。


在下文中一共展示了OutputStream.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyStream

 /// <exception cref="System.IO.IOException"></exception>
 public static void CopyStream(InputStream @is, OutputStream os)
 {
     int n;
     byte[] buffer = new byte[16384];
     while ((n = @is.Read(buffer)) > -1)
     {
         os.Write(buffer, 0, n);
     }
     os.Close();
     @is.Close();
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:12,代码来源:StreamUtils.cs

示例2: WriteTo

		/// <exception cref="System.IO.IOException"></exception>
		public override void WriteTo(OutputStream @out)
		{
			if (@out == null)
			{
				throw new ArgumentException("Output stream may not be null");
			}
			try
			{
				byte[] tmp = new byte[4096];
				int l;
				while ((l = [email protected](tmp)) != -1)
				{
					@out.Write(tmp, 0, l);
				}
				@out.Flush();
			}
			finally
			{
				[email protected]();
			}
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:22,代码来源:InputStreamBody.cs

示例3: WriteTo

 /// <exception cref="System.IO.IOException"></exception>
 public override void WriteTo(OutputStream @out)
 {
     @out.Write(data);
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:5,代码来源:ByteArrayBody.cs

示例4: _get

		/// <exception cref="NSch.SftpException"></exception>
		private void _get(string src, OutputStream dst, SftpProgressMonitor monitor, int 
			mode, long skip)
		{
			//System.err.println("_get: "+src+", "+dst);
			byte[] srcb = Util.Str2byte(src, fEncoding);
			try
			{
				SendOPENR(srcb);
				ChannelHeader header = new ChannelHeader(this);
				header = Header(buf, header);
				int length = header.length;
				int type = header.type;
				Fill(buf, length);
				if (type != SSH_FXP_STATUS && type != SSH_FXP_HANDLE)
				{
					throw new SftpException(SSH_FX_FAILURE, string.Empty);
				}
				if (type == SSH_FXP_STATUS)
				{
					int i = buf.GetInt();
					ThrowStatusError(buf, i);
				}
				byte[] handle = buf.GetString();
				// filename
				long offset = 0;
				if (mode == RESUME)
				{
					offset += skip;
				}
				int request_len = 0;
				while (true)
				{
					request_len = buf.buffer.Length - 13;
					if (server_version == 0)
					{
						request_len = 1024;
					}
					SendREAD(handle, offset, request_len);
					header = Header(buf, header);
					length = header.length;
					type = header.type;
					if (type == SSH_FXP_STATUS)
					{
						Fill(buf, length);
						int i = buf.GetInt();
						if (i == SSH_FX_EOF)
						{
							goto loop_break;
						}
						ThrowStatusError(buf, i);
					}
					if (type != SSH_FXP_DATA)
					{
						goto loop_break;
					}
					buf.Rewind();
					Fill(buf.buffer, 0, 4);
					length -= 4;
					int i_1 = buf.GetInt();
					// length of data 
					int foo = i_1;
					while (foo > 0)
					{
						int bar = foo;
						if (bar > buf.buffer.Length)
						{
							bar = buf.buffer.Length;
						}
						i_1 = io_in.Read(buf.buffer, 0, bar);
						if (i_1 < 0)
						{
							goto loop_break;
						}
						int data_len = i_1;
						dst.Write(buf.buffer, 0, data_len);
						offset += data_len;
						foo -= data_len;
						if (monitor != null)
						{
							if (!monitor.Count(data_len))
							{
								while (foo > 0)
								{
									i_1 = io_in.Read(buf.buffer, 0, (buf.buffer.Length < foo ? buf.buffer.Length : foo
										));
									if (i_1 <= 0)
									{
										break;
									}
									foo -= i_1;
								}
								goto loop_break;
							}
						}
					}
loop_continue: ;
				}
loop_break: ;
				//System.err.println("length: "+length);  // length should be 0
//.........这里部分代码省略.........
开发者ID:yayanyang,项目名称:monodevelop,代码行数:101,代码来源:ChannelSftp.cs

示例5: WriteSECSHPublicKey

		public virtual void WriteSECSHPublicKey(OutputStream @out, string comment)
		{
			byte[] pubblob = GetPublicKeyBlob();
			byte[] pub = Util.ToBase64(pubblob, 0, pubblob.Length);
			try
			{
				@out.Write(Util.Str2byte("---- BEGIN SSH2 PUBLIC KEY ----"));
				@out.Write(cr);
				@out.Write(Util.Str2byte("Comment: \"" + comment + "\""));
				@out.Write(cr);
				int index = 0;
				while (index < pub.Length)
				{
					int len = 70;
					if ((pub.Length - index) < len)
					{
						len = pub.Length - index;
					}
					@out.Write(pub, index, len);
					@out.Write(cr);
					index += len;
				}
				@out.Write(Util.Str2byte("---- END SSH2 PUBLIC KEY ----"));
				@out.Write(cr);
			}
			catch (Exception)
			{
			}
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:29,代码来源:KeyPair.cs

示例6: Dump

		/// <exception cref="System.IO.IOException"></exception>
		internal virtual void Dump(OutputStream @out)
		{
			try
			{
				HostKey hk;
				lock (pool)
				{
					for (int i = 0; i < pool.Count; i++)
					{
						hk = (HostKey)(pool[i]);
						//hk.dump(out);
						string host = hk.GetHost();
						string type = hk.GetType();
						if (type.Equals("UNKNOWN"))
						{
							@out.Write(Util.Str2byte(host));
							@out.Write(cr);
							continue;
						}
						@out.Write(Util.Str2byte(host));
						@out.Write(space);
						@out.Write(Util.Str2byte(type));
						@out.Write(space);
						@out.Write(Util.Str2byte(hk.GetKey()));
						@out.Write(cr);
					}
				}
			}
			catch (Exception e)
			{
				System.Console.Error.WriteLine(e);
			}
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:34,代码来源:KnownHosts.cs

示例7: WriteTo

		/// <exception cref="System.IO.IOException"></exception>
		public override void WriteTo(OutputStream @out)
		{
			if (@out == null)
			{
				throw new ArgumentException("Output stream may not be null");
			}
			InputStream @in = new ByteArrayInputStream(this.content);
			byte[] tmp = new byte[4096];
			int l;
			while ((l = @in.Read(tmp)) != -1)
			{
				@out.Write(tmp, 0, l);
			}
			@out.Flush();
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:16,代码来源:StringBody.cs

示例8: SwitchToOverflow

		/// <exception cref="System.IO.IOException"></exception>
		private void SwitchToOverflow()
		{
			overflow = Overflow();
			TemporaryBuffer.Block last = blocks.Remove(blocks.Count - 1);
			foreach (TemporaryBuffer.Block b in blocks)
			{
				overflow.Write(b.buffer, 0, b.count);
			}
			blocks = null;
			overflow = new BufferedOutputStream(overflow, TemporaryBuffer.Block.SZ);
			overflow.Write(last.buffer, 0, last.count);
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:13,代码来源:TemporaryBuffer.cs

示例9: FormatMerge

		/// <summary>
		/// Formats the results of a merge of
		/// <see cref="NGit.Diff.RawText">NGit.Diff.RawText</see>
		/// objects in a Git
		/// conformant way. This method also assumes that the
		/// <see cref="NGit.Diff.RawText">NGit.Diff.RawText</see>
		/// objects
		/// being merged are line oriented files which use LF as delimiter. This
		/// method will also use LF to separate chunks and conflict metadata,
		/// therefore it fits only to texts that are LF-separated lines.
		/// </summary>
		/// <param name="out">the outputstream where to write the textual presentation</param>
		/// <param name="res">the merge result which should be presented</param>
		/// <param name="seqName">
		/// When a conflict is reported each conflicting range will get a
		/// name. This name is following the "<&lt;&lt;&lt;&lt;&lt;&lt; " or ">&gt;&gt;&gt;&gt;&gt;&gt; "
		/// conflict markers. The names for the sequences are given in
		/// this list
		/// </param>
		/// <param name="charsetName">
		/// the name of the characterSet used when writing conflict
		/// metadata
		/// </param>
		/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
		public virtual void FormatMerge(OutputStream @out, MergeResult<RawText> res, IList
			<string> seqName, string charsetName)
		{
			string lastConflictingName = null;
			// is set to non-null whenever we are
			// in a conflict
			bool threeWayMerge = (res.GetSequences().Count == 3);
			foreach (MergeChunk chunk in res)
			{
				RawText seq = res.GetSequences()[chunk.GetSequenceIndex()];
				if (lastConflictingName != null && chunk.GetConflictState() != MergeChunk.ConflictState
					.NEXT_CONFLICTING_RANGE)
				{
					// found the end of an conflict
					@out.Write(Sharpen.Runtime.GetBytesForString((">>>>>>> " + lastConflictingName + 
						"\n"), charsetName));
					lastConflictingName = null;
				}
				if (chunk.GetConflictState() == MergeChunk.ConflictState.FIRST_CONFLICTING_RANGE)
				{
					// found the start of an conflict
					@out.Write(Sharpen.Runtime.GetBytesForString(("<<<<<<< " + seqName[chunk.GetSequenceIndex
						()] + "\n"), charsetName));
					lastConflictingName = seqName[chunk.GetSequenceIndex()];
				}
				else
				{
					if (chunk.GetConflictState() == MergeChunk.ConflictState.NEXT_CONFLICTING_RANGE)
					{
						// found another conflicting chunk
						lastConflictingName = seqName[chunk.GetSequenceIndex()];
						@out.Write(Sharpen.Runtime.GetBytesForString((threeWayMerge ? "=======\n" : "======= "
							 + lastConflictingName + "\n"), charsetName));
					}
				}
				// the lines with conflict-metadata are written. Now write the chunk
				for (int i = chunk.GetBegin(); i < chunk.GetEnd(); i++)
				{
					seq.WriteLine(@out, i);
					@out.Write('\n');
				}
			}
			// one possible leftover: if the merge result ended with a conflict we
			// have to close the last conflict here
			if (lastConflictingName != null)
			{
				@out.Write(Sharpen.Runtime.GetBytesForString((">>>>>>> " + lastConflictingName + 
					"\n"), charsetName));
			}
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:74,代码来源:MergeFormatter.cs

示例10: CopyTo

 /// <summary>Copy this mode as a sequence of octal US-ASCII bytes.</summary>
 /// <remarks>
 /// Copy this mode as a sequence of octal US-ASCII bytes.
 /// <p/>
 /// The mode is copied as a sequence of octal digits using the US-ASCII
 /// character encoding. The sequence does not use a leading '0' prefix to
 /// indicate octal notation. This method is suitable for generation of a mode
 /// string within a GIT tree object.
 /// </p>
 /// </remarks>
 /// <param name="os">stream to copy the mode to.</param>
 /// <exception cref="System.IO.IOException">the stream encountered an error during the copy.
 /// 	</exception>
 public virtual void CopyTo(OutputStream os)
 {
     os.Write(octalBytes);
 }
开发者ID:sharwell,项目名称:ngit,代码行数:17,代码来源:FileMode.cs

示例11: WriteRawInt

 /// <exception cref="System.IO.IOException"></exception>
 private static void WriteRawInt(OutputStream w, int v)
 {
     w.Write((int)(((uint)v) >> 24));
     w.Write((int)(((uint)v) >> 16));
     w.Write((int)(((uint)v) >> 8));
     w.Write(v);
 }
开发者ID:sharwell,项目名称:ngit,代码行数:8,代码来源:AnyObjectId.cs

示例12: CopyTo

 /// <summary>Copy this ObjectId to an output writer in hex format.</summary>
 /// <remarks>Copy this ObjectId to an output writer in hex format.</remarks>
 /// <param name="w">the stream to copy to.</param>
 /// <exception cref="System.IO.IOException">the stream writing failed.</exception>
 public virtual void CopyTo(OutputStream w)
 {
     w.Write(ToHexByteArray());
 }
开发者ID:sharwell,项目名称:ngit,代码行数:8,代码来源:AnyObjectId.cs

示例13: CopyTo

 /// <summary>Copy this object to the output stream.</summary>
 /// <remarks>
 /// Copy this object to the output stream.
 /// <p/>
 /// For some object store implementations, this method may be more efficient
 /// than reading from
 /// <see cref="OpenStream()">OpenStream()</see>
 /// into a temporary byte array, then
 /// writing to the destination stream.
 /// <p/>
 /// The default implementation of this method is to copy with a temporary
 /// byte array for large objects, or to pass through the cached byte array
 /// for small objects.
 /// </remarks>
 /// <param name="out">
 /// stream to receive the complete copy of this object's data.
 /// Caller is responsible for flushing or closing this stream
 /// after this method returns.
 /// </param>
 /// <exception cref="NGit.Errors.MissingObjectException">the object no longer exists.
 /// 	</exception>
 /// <exception cref="System.IO.IOException">
 /// the object store cannot be accessed, or the stream cannot be
 /// written to.
 /// </exception>
 public virtual void CopyTo(OutputStream @out)
 {
     if (IsLarge())
     {
         ObjectStream @in = OpenStream();
         try
         {
             long sz = @in.GetSize();
             byte[] tmp = new byte[8192];
             long copied = 0;
             while (copied < sz)
             {
                 int n = @in.Read(tmp);
                 if (n < 0)
                 {
                     throw new EOFException();
                 }
                 @out.Write(tmp, 0, n);
                 copied += n;
             }
             if (0 <= @in.Read())
             {
                 throw new EOFException();
             }
         }
         finally
         {
             @in.Close();
         }
     }
     else
     {
         @out.Write(GetCachedBytes());
     }
 }
开发者ID:sharwell,项目名称:ngit,代码行数:60,代码来源:ObjectLoader.cs

示例14: Write

 /// <exception cref="System.IO.IOException"></exception>
 internal virtual void Write(OutputStream os)
 {
     int len = IsExtended ? INFO_LEN_EXTENDED : INFO_LEN;
     int pathLen = path.Length;
     os.Write(info, infoOffset, len);
     os.Write(path, 0, pathLen);
     // Index records are padded out to the next 8 byte alignment
     // for historical reasons related to how C Git read the files.
     //
     int actLen = len + pathLen;
     int expLen = (actLen + 8) & ~7;
     if (actLen != expLen)
     {
         os.Write(nullpad, 0, expLen - actLen);
     }
 }
开发者ID:sharwell,项目名称:ngit,代码行数:17,代码来源:DirCacheEntry.cs

示例15: WriteBytes

 /// <exception cref="System.IO.IOException"></exception>
 private static void WriteBytes(ByteArrayBuffer b, OutputStream @out)
 {
     @out.Write(b.Buffer(), 0, b.Length());
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:5,代码来源:HttpMultipart.cs


注:本文中的Sharpen.OutputStream.Write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。