當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。