public KaldiTextParser(string path) { File file = new File(path, "final.mdl"); InputStream inputStream = new URL(file.getPath()).openStream(); File file2 = new File(path, "tree"); InputStream inputStream2 = new URL(file2.getPath()).openStream(); SequenceInputStream sequenceInputStream = new SequenceInputStream(inputStream, inputStream2); this.scanner = new Scanner(sequenceInputStream); }
public void Test1() { using var stream = new SequenceInputStream(EnumerableEx.Concat(new[] { new MemoryStream("123".Bytes()), new MemoryStream("456".Bytes()), new MemoryStream("789".Bytes()), }).ToArray()); using var reader = new StreamReader(stream); Assert.Equal("123456789", reader.ReadToEnd()); }
/// <summary> /// Initializes a ConcatFileDataSource. /// </summary> public override void Initialize() { base.Initialize(); if (_batchFiles == null) { return; } try { References = new List <String>(); DataStream = new SequenceInputStream(new InputStreamEnumeration(this, _batchFiles)); } catch (IOException e) { Trace.TraceError(e.Message); } }
/* * Reads GZIP member trailer and returns true if the eos * reached, false if there are more (concatenated gzip * data set) */ //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private boolean readTrailer() throws java.io.IOException private bool ReadTrailer() { InputStream @in = this.@in; int n = Inf.Remaining; if (n > 0) { @in = new SequenceInputStream(new ByteArrayInputStream(Buf, Len - n, n), new FilterInputStreamAnonymousInnerClassHelper(this, @in)); } // Uses left-to-right evaluation order if ((ReadUInt(@in) != Crc.Value) || (ReadUInt(@in) != (Inf.BytesWritten & 0xffffffffL))) { // rfc1952; ISIZE is the input size modulo 2^32 throw new ZipException("Corrupt GZIP trailer"); } // If there are more bytes available in "in" or // the leftover in the "inf" is > 26 bytes: // this.trailer(8) + next.header.min(10) + next.trailer(8) // try concatenated case if ([email protected]() > 0 || n > 26) { int m = 8; // this.trailer try { m += ReadHeader(@in); // next.header } catch (IOException) { return(true); // ignore any malformed, do nothing } Inf.Reset(); if (n > m) { Inf.SetInput(Buf, Len - n + m, n - m); } return(false); } return(true); }