Questions tagged [stream]

DO NOT USE FOR THE JAVA STREAM API INTRODUCED IN JAVA 8 (use [java-stream] for those questions!) A stream is a series of data elements which can be accessed in a serial fashion.

A stream is a series of data elements (characters, bytes or complex packets) which can be accessed or made accessible in a serial fashion. Random access is not possible.

The term stream is also used for streaming media, a method in which the media can be played while it is being accessed (no full download required). The ability to stream media is largely dependent on the container format used. Seeking functionality in streaming media is typically achieved through a different protocol, for example RTSP or HTTP 1.1's Range function.

15725 questions
53
votes
3 answers

Stream as a return value in WCF - who disposes it?

Let's say I have the following WCF implementation: public Stream Download(string path) { FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read); return stream; } Who's responsible for disposing the returned value? After…
Ron Klein
  • 9,178
  • 9
  • 55
  • 88
52
votes
4 answers

changing the delimiter for cin (c++)

I've redirected "cin" to read from a file stream cin.rdbug(inF.rdbug()) When I use the extraction operator it reads until it reaches a white space character. Is it possible to use another delimiter? I went through the api in cplusplus.com, but…
yotamoo
  • 5,334
  • 13
  • 49
  • 61
52
votes
6 answers

Closing Streams in Java

Why do we need to close a FileInputStream (and streams in general) in any case before we leave the program? What would happen otherwise? If the program stops before the input stream is closed explicitly in the program, doesn't the stream also close…
user42155
  • 48,965
  • 27
  • 59
  • 60
52
votes
6 answers

Obtaining the hash of a file using the stream capabilities of crypto module (ie: without hash.update and hash.digest)

The crypto module of node.js (at the time of this writing at least) is not still deemed stable and so the API may change. In fact, the methods that everyone in the internet use to get the hash (md5, sha1, ...) of a file are considered legacy (from…
Carlos Campderrós
  • 22,354
  • 11
  • 51
  • 57
51
votes
5 answers

Infinite streams in Scala

Say I have a function, for example the old favourite def factorial(n:Int) = (BigInt(1) /: (1 to n)) (_*_) Now I want to find the biggest value of n for which factorial(n) fits in a Long. I could do (1 to 100) takeWhile (factorial(_) <=…
Luigi Plinge
  • 50,650
  • 20
  • 113
  • 180
51
votes
4 answers

Use-cases for Streams in Scala

In Scala there is a Stream class that is very much like an iterator. The topic Difference between Iterator and Stream in Scala? offers some insights into the similarities and differences between the two. Seeing how to use a stream is pretty simple…
Jesse Eichar
  • 1,081
  • 1
  • 11
  • 11
50
votes
2 answers

Do you need to call Flush() on a stream or writer if you are using the “using” statement?

I am not sure whether I need to call Flush() on the used objects if I write something like this: using (FileStream...) using (CryptoStream...) using (BinaryWriter...) { // do something } Are they always automatically flushed? When does the…
Ben
  • 2,435
  • 6
  • 43
  • 57
50
votes
8 answers

Creating Zip file from stream and downloading it

I have a DataTable that i want to convert it to xml and then zip it, using DotNetZip. finally user can download it via Asp.Net webpage. My code in below dt.TableName = "Declaration"; MemoryStream stream = new MemoryStream(); …
Navid Farhadi
  • 3,397
  • 2
  • 28
  • 34
50
votes
6 answers

Edit a specific Line of a Text File in C#

I have two text files, Source.txt and Target.txt. The source will never be modified and contain N lines of text. So, I want to delete a specific line of text in Target.txt, and replace by an specific line of text from Source.txt, I know what number…
Luis
  • 503
  • 1
  • 4
  • 4
49
votes
5 answers

s3.getObject().createReadStream() : How to catch the error?

I am trying to write a program to get a zip file from s3, unzip it, then upload it to S3. But I found two exceptions that I can not catch. 1. StreamContentLengthMismatch: Stream content length mismatch. Received 980323883 of 5770104761 bytes. This…
49
votes
7 answers

Printing Runtime exec() OutputStream to console

I am trying to get the OutputStream of the Process initiated by exec() to the console. How can this be done? Here is some incomplete code: import java.io.BufferedReader; import java.io.File; import java.io.IOException; import…
TheWolf
  • 1,675
  • 4
  • 22
  • 34
49
votes
5 answers

PDFsharp save to MemoryStream

I want to save a PdfSharp.Pdf.PdfDocument by its Save method to a Stream, but it doesn't attach the PDF header settings to it. So when I read back the Stream and return it to the user, he see that the PDF file is invalid. Is there a solution to…
misnyo
  • 1,707
  • 3
  • 16
  • 17
46
votes
10 answers

Treating an SQL ResultSet like a Scala Stream

When I query a database and receive a (forward-only, read-only) ResultSet back, the ResultSet acts like a list of database rows. I am trying to find some way to treat this ResultSet like a Scala Stream. This will allow such operations as filter,…
Ralph
  • 31,584
  • 38
  • 145
  • 282
46
votes
5 answers

Buffered files (for faster disk access)

I am working with large files and writing directly to disk is slow. Because the file is large I cannot load it in a TMemoryStream. TFileStream is not buffered so I want to know if there is a custom library that can offer buffered streams or should I…
Gabriel
  • 20,797
  • 27
  • 159
  • 293
46
votes
8 answers

Video streaming with HTML 5 via node.js

I'm trying to set up a web server that will support streaming video to an HTML5 video tag using node.js. Here's my code so far: var range = request.headers.range; var total = file.length; var parts = range.replace(/bytes=/, "").split("-"); var…
Chris Harrington
  • 1,593
  • 3
  • 17
  • 26