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


C# Sharpen.FileInputStream类代码示例

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


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

示例1: Test1

		public virtual void Test1()
		{
			FilePath packFile = JGitTestUtil.GetTestResourceFile("pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.pack"
				);
			InputStream @is = new FileInputStream(packFile);
			try
			{
				ObjectDirectoryPackParser p = (ObjectDirectoryPackParser)Index(@is);
				p.Parse(NullProgressMonitor.INSTANCE);
				PackFile file = p.GetPackFile();
				NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("4b825dc642cb6eb9a060e54bf8d69288fbee4904"
					)));
				NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("540a36d136cf413e4b064c2b0e0a4db60f77feab"
					)));
				NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259"
					)));
				NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("6ff87c4664981e4397625791c8ea3bbb5f2279a3"
					)));
				NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("82c6b885ff600be425b4ea96dee75dca255b69e7"
					)));
				NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("902d5476fa249b7abc9d84c611577a81381f0327"
					)));
				NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("aabf2ffaec9b497f0950352b3e582d73035c2035"
					)));
				NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("c59759f143fb1fe21c197981df75a7ee00290799"
					)));
			}
			finally
			{
				@is.Close();
			}
		}
开发者ID:shoff,项目名称:ngit,代码行数:32,代码来源:PackParserTest.cs

示例2: CopyFile

		/// <exception cref="System.IO.IOException"></exception>
		public static void CopyFile(FilePath sourceFile, FilePath destFile)
		{
			if (!destFile.Exists())
			{
				destFile.CreateNewFile();
			}
			FileChannel source = null;
			FileChannel destination = null;
			try
			{
				source = new FileInputStream(sourceFile).GetChannel();
				destination = new FileOutputStream(destFile).GetChannel();
				destination.TransferFrom(source, 0, source.Size());
			}
			finally
			{
				if (source != null)
				{
					source.Close();
				}
				if (destination != null)
				{
					destination.Close();
				}
			}
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:27,代码来源:FileDirUtils.cs

示例3: ReadFully

		/// <summary>Read an entire local file into memory as a byte array.</summary>
		/// <remarks>Read an entire local file into memory as a byte array.</remarks>
		/// <param name="path">location of the file to read.</param>
		/// <param name="max">
		/// maximum number of bytes to read, if the file is larger than
		/// this limit an IOException is thrown.
		/// </param>
		/// <returns>complete contents of the requested local file.</returns>
		/// <exception cref="System.IO.FileNotFoundException">the file does not exist.</exception>
		/// <exception cref="System.IO.IOException">the file exists, but its contents cannot be read.
		/// 	</exception>
		public static byte[] ReadFully(FilePath path, int max)
		{
			FileInputStream @in = new FileInputStream(path);
			try
			{
				long sz = @in.GetChannel().Size();
				if (sz > max)
				{
					throw new IOException(MessageFormat.Format(JGitText.Get().fileIsTooLarge, path));
				}
				byte[] buf = new byte[(int)sz];
				IOUtil.ReadFully(@in, buf, 0, buf.Length);
				return buf;
			}
			finally
			{
				try
				{
					@in.Close();
				}
				catch (IOException)
				{
				}
			}
		}
开发者ID:nickname100,项目名称:monodevelop,代码行数:36,代码来源:IOUtil.cs

示例4: CopyFile

		/// <exception cref="System.IO.IOException"></exception>
		protected internal static void CopyFile(FilePath src, FilePath dst)
		{
			FileInputStream fis = new FileInputStream(src);
			try
			{
				FileOutputStream fos = new FileOutputStream(dst);
				try
				{
					byte[] buf = new byte[4096];
					int r;
					while ((r = fis.Read(buf)) > 0)
					{
						fos.Write(buf, 0, r);
					}
				}
				finally
				{
					fos.Close();
				}
			}
			finally
			{
				fis.Close();
			}
		}
开发者ID:shoff,项目名称:ngit,代码行数:26,代码来源:RepositoryTestCase.cs

示例5: ReadSome

		/// <summary>Read at most limit bytes from the local file into memory as a byte array.
		/// 	</summary>
		/// <remarks>Read at most limit bytes from the local file into memory as a byte array.
		/// 	</remarks>
		/// <param name="path">location of the file to read.</param>
		/// <param name="limit">
		/// maximum number of bytes to read, if the file is larger than
		/// only the first limit number of bytes are returned
		/// </param>
		/// <returns>
		/// complete contents of the requested local file. If the contents
		/// exceeds the limit, then only the limit is returned.
		/// </returns>
		/// <exception cref="System.IO.FileNotFoundException">the file does not exist.</exception>
		/// <exception cref="System.IO.IOException">the file exists, but its contents cannot be read.
		/// 	</exception>
		public static byte[] ReadSome(FilePath path, int limit)
		{
			FileInputStream @in = new FileInputStream(path);
			try
			{
				byte[] buf = new byte[limit];
				int cnt = 0;
				for (; ; )
				{
					int n = @in.Read(buf, cnt, buf.Length - cnt);
					if (n <= 0)
					{
						break;
					}
					cnt += n;
				}
				if (cnt == buf.Length)
				{
					return buf;
				}
				byte[] res = new byte[cnt];
				System.Array.Copy(buf, 0, res, 0, cnt);
				return res;
			}
			finally
			{
				try
				{
					@in.Close();
				}
				catch (IOException)
				{
				}
			}
		}
开发者ID:nocache,项目名称:monodevelop,代码行数:51,代码来源:IOUtil.cs

示例6: ProcessBytes

		public static GifHeaderDirectory ProcessBytes(string file)
		{
			Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata();
			InputStream stream = new FileInputStream(file);
			new GifReader().Extract(new Com.Drew.Lang.StreamReader(stream), metadata);
			stream.Close();
			GifHeaderDirectory directory = metadata.GetDirectory<GifHeaderDirectory>();
			NUnit.Framework.Assert.IsNotNull(directory);
			return directory;
		}
开发者ID:renaud91,项目名称:n-metadata-extractor,代码行数:10,代码来源:GifReaderTest.cs

示例7: SetKnownHosts

		/// <exception cref="NSch.JSchException"></exception>
		internal virtual void SetKnownHosts(string foo)
		{
			try
			{
				known_hosts = foo;
				FileInputStream fis = new FileInputStream(foo);
				SetKnownHosts(fis);
			}
			catch (FileNotFoundException)
			{
			}
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:13,代码来源:KnownHosts.cs

示例8: ProcessFile

 private static Com.Drew.Metadata.Metadata ProcessFile([NotNull] string filePath)
 {
     FileInputStream inputStream = null;
     try
     {
         inputStream = new FileInputStream(filePath);
         return PngMetadataReader.ReadMetadata(inputStream);
     }
     finally
     {
         if (inputStream != null)
         {
             inputStream.Close();
         }
     }
 }
开发者ID:Sicos1977,项目名称:n-metadata-extractor,代码行数:16,代码来源:PngMetadataReaderTest.cs

示例9: ReadMetadata

		public static Com.Drew.Metadata.Metadata ReadMetadata(FilePath file, Iterable<JpegSegmentMetadataReader> readers)
		{
			InputStream inputStream = null;
			try
			{
				inputStream = new FileInputStream(file);
				return ReadMetadata(inputStream, readers);
			}
			finally
			{
				if (inputStream != null)
				{
					inputStream.Close();
				}
			}
		}
开发者ID:renaud91,项目名称:n-metadata-extractor,代码行数:16,代码来源:JpegMetadataReader.cs

示例10: ProcessFile

		/// <exception cref="Com.Drew.Imaging.Png.PngProcessingException"/>
		/// <exception cref="System.IO.IOException"/>
		public static IList<PngChunk> ProcessFile(string filePath)
		{
			FileInputStream inputStream = null;
			try
			{
				inputStream = new FileInputStream(filePath);
				return Iterables.ToList(new PngChunkReader().Extract(new Com.Drew.Lang.StreamReader(inputStream), null));
			}
			finally
			{
				if (inputStream != null)
				{
					inputStream.Close();
				}
			}
		}
开发者ID:renaud91,项目名称:n-metadata-extractor,代码行数:18,代码来源:PngChunkReaderTest.cs

示例11: ReadMetadata

		public static Com.Drew.Metadata.Metadata ReadMetadata(FilePath file)
		{
			FileInputStream stream = null;
			try
			{
				stream = new FileInputStream(file);
				return ReadMetadata(stream);
			}
			finally
			{
				if (stream != null)
				{
					stream.Close();
				}
			}
		}
开发者ID:renaud91,项目名称:n-metadata-extractor,代码行数:16,代码来源:BmpMetadataReader.cs

示例12: VisitFile

		/// <exception cref="System.IO.IOException"></exception>
		public override void VisitFile(FileTreeEntry f)
		{
			FilePath path = new FilePath(GetCurrentDirectory(), f.GetName());
			FileInputStream @in = new FileInputStream(path);
			try
			{
				long sz = @in.GetChannel().Size();
				f.SetId(inserter.Insert(Constants.OBJ_BLOB, sz, @in));
				inserter.Flush();
			}
			finally
			{
				inserter.Release();
				@in.Close();
			}
		}
开发者ID:famousthom,项目名称:monodevelop,代码行数:17,代码来源:WriteTree.cs

示例13: ReadSegments

		public static JpegSegmentData ReadSegments(FilePath file, Iterable<JpegSegmentType> segmentTypes)
		{
			FileInputStream stream = null;
			try
			{
				stream = new FileInputStream(file);
				return ReadSegments(new Com.Drew.Lang.StreamReader(stream), segmentTypes);
			}
			finally
			{
				if (stream != null)
				{
					stream.Close();
				}
			}
		}
开发者ID:renaud91,项目名称:n-metadata-extractor,代码行数:16,代码来源:JpegSegmentReader.cs

示例14: ProcessBytes

 public static PsdHeaderDirectory ProcessBytes([NotNull] string file)
 {
     Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata();
     InputStream stream = new FileInputStream(new FilePath(file));
     try
     {
         new PsdReader().Extract(new Com.Drew.Lang.StreamReader(stream), metadata);
     }
     catch (Exception e)
     {
         stream.Close();
         throw;
     }
     PsdHeaderDirectory directory = metadata.GetFirstDirectoryOfType<PsdHeaderDirectory>();
     NUnit.Framework.Assert.IsNotNull(directory);
     return directory;
 }
开发者ID:Sicos1977,项目名称:n-metadata-extractor,代码行数:17,代码来源:PsdReaderTest.cs

示例15: Test2

 public virtual void Test2()
 {
     FilePath packFile = JGitTestUtil.GetTestResourceFile("pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371.pack"
         );
     InputStream @is = new FileInputStream(packFile);
     try
     {
         ObjectDirectoryPackParser p = (ObjectDirectoryPackParser)Index(@is);
         p.Parse(NullProgressMonitor.INSTANCE);
         PackFile file = p.GetPackFile();
         NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("02ba32d3649e510002c21651936b7077aa75ffa9"
             )));
         NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("0966a434eb1a025db6b71485ab63a3bfbea520b6"
             )));
         NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("09efc7e59a839528ac7bda9fa020dc9101278680"
             )));
         NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("0a3d7772488b6b106fb62813c4d6d627918d9181"
             )));
         NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("1004d0d7ac26fbf63050a234c9b88a46075719d3"
             )));
         NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("10da5895682013006950e7da534b705252b03be6"
             )));
         NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("1203b03dc816ccbb67773f28b3c19318654b0bc8"
             )));
         NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("15fae9e651043de0fd1deef588aa3fbf5a7a41c6"
             )));
         NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("16f9ec009e5568c435f473ba3a1df732d49ce8c3"
             )));
         NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("1fd7d579fb6ae3fe942dc09c2c783443d04cf21e"
             )));
         NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("20a8ade77639491ea0bd667bf95de8abf3a434c8"
             )));
         NUnit.Framework.Assert.IsTrue(file.HasObject(ObjectId.FromString("2675188fd86978d5bc4d7211698b2118ae3bf658"
             )));
     }
     finally
     {
         // and lots more...
         @is.Close();
     }
 }
开发者ID:JamesChan,项目名称:ngit,代码行数:41,代码来源:PackParserTest.cs


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