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


C# Writer.flush方法代码示例

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


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

示例1: writeHeader

//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: public static VCFHeader writeHeader(VCFHeader header, final Writer writer, final boolean doNotWriteGenotypes, final String versionLine, final String streamNameForError)
		public static VCFHeader writeHeader(VCFHeader header, Writer writer, bool doNotWriteGenotypes, string versionLine, string streamNameForError)
		{
			header = doNotWriteGenotypes ? new VCFHeader(header.MetaDataInSortedOrder) : header;

			try
			{
				// the file format field needs to be written first
				writer.write(versionLine + "\n");

				foreach (VCFHeaderLine line in header.MetaDataInSortedOrder)
				{
					if (VCFHeaderVersion.isFormatString(line.Key))
					{
						continue;
					}

					writer.write(VCFHeader.METADATA_INDICATOR);
					writer.write(line.ToString());
					writer.write("\n");
				}

				// write out the column line
				writer.write(VCFHeader.HEADER_INDICATOR);
				bool isFirst = true;
				foreach (string field in VCFHeader.HEADER_FIELDS)
				{
					if (isFirst)
					{
						isFirst = false; // don't write out a field separator
					}
					else
					{
						writer.write(VCFConstants.FIELD_SEPARATOR);
					}
					writer.write(field.ToString());
				}

				if (header.hasGenotypingData())
				{
					writer.write(VCFConstants.FIELD_SEPARATOR);
					writer.write("FORMAT");
					foreach (string sample in header.GenotypeSampleNames)
					{
						writer.write(VCFConstants.FIELD_SEPARATOR);
						writer.write(sample);
					}
				}

				writer.write("\n");
				writer.flush(); // necessary so that writing to an output stream will work
			}
			catch (IOException e)
			{
				throw new Exception("IOException writing the VCF header to " + streamNameForError, e);
			}

			return header;
		}
开发者ID:w3he,项目名称:Bio.VCF,代码行数:60,代码来源:VCFWriter.cs


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