public static void Load(this Hashtable props, InputStream stream) { using (var reader = new InputStreamReader(stream, Encoding.UTF8)) { while (!reader.EndOfStream) { var line = reader.ReadLine(); if (!String.IsNullOrWhiteSpace(line) && !line.StartsWith("#")) { var parts = line.Split('='); if (parts.Length != 2) throw new InvalidOperationException("Properties must be key value pairs separated by an '='."); if (!props.ContainsKey(parts[0])) props.Add(parts[0], parts[1]); else props[parts[0]] = parts[1]; } } } }
/// <exception cref="System.IO.IOException"></exception> protected internal static void CheckFile(FilePath f, string checkData) { StreamReader r = new InputStreamReader(new FileInputStream(f), "ISO-8859-1"); try { char[] data = new char[(int)f.Length()]; if (f.Length() != r.Read(data)) { throw new IOException("Internal error reading file data from " + f); } NUnit.Framework.Assert.AreEqual(checkData, new string(data)); } finally { r.Close(); } }
public BufferedReader (InputStreamReader r) : base(r.BaseStream) { }
/// <exception cref="System.IO.IOException"></exception> private string ReadTestPatchFile(Encoding cs) { string patchFile = Sharpen.Extensions.GetTestName() + ".patch"; InputStream @in = GetType().GetResourceAsStream(patchFile); if (@in == null) { NUnit.Framework.Assert.Fail("No " + patchFile + " test vector"); return null; } // Never happens try { InputStreamReader r = new InputStreamReader(@in, cs); char[] tmp = new char[2048]; StringBuilder s = new StringBuilder(); int n; while ((n = r.Read(tmp)) > 0) { s.Append(tmp, 0, n); } return s.ToString(); } finally { @in.Close(); } }
public BufferedReader(InputStreamReader r) : base(r.BaseStream) { }