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
135
votes
5 answers

How to get error message when ifstream open fails

ifstream f; f.open(fileName); if ( f.fail() ) { // I need error message here, like "File not found" etc. - // the reason of the failure } How to get error message as string?
Alex F
  • 42,307
  • 41
  • 144
  • 212
135
votes
7 answers

C# using streams

Streams are kind of mysterious to me. I don't know when to use which stream and how to use them. Can someone explain to me how streams are used? If I understand correctly, there are three stream types: stream read stream write stream Is this…
Martijn
  • 24,441
  • 60
  • 174
  • 261
134
votes
5 answers

Is there any way to close a StreamWriter without closing its BaseStream?

My root problem is that when using calls Dispose on a StreamWriter, it also disposes the BaseStream (same problem with Close). I have a workaround for this, but as you can see, it involves copying the stream. Is there any way to do this without…
Binary Worrier
  • 50,774
  • 20
  • 136
  • 184
132
votes
2 answers

Difference between `open` and `io.BytesIO` in binary streams

I'm learning about working with streams in Python and I noticed that the IO docs say the following: The easiest way to create a binary stream is with open() with 'b' in the mode string: f = open("myfile.jpg", "rb") In-memory binary streams are also…
Luke Whyte
  • 1,407
  • 2
  • 11
  • 10
131
votes
10 answers

How to close a readable stream (before end)?

How to close a readable stream in Node.js? var input = fs.createReadStream('lines.txt'); input.on('data', function(data) { // after closing the stream, this will not // be called again if (gotFirstLine) { // close this stream and…
Ionică Bizău
  • 109,027
  • 88
  • 289
  • 474
122
votes
13 answers

"The given path's format is not supported."

I have the following code in my web service: string str_uploadpath = Server.MapPath("/UploadBucket/Raw/"); FileStream objfilestream = new FileStream(str_uploadpath + fileName, FileMode.Create, FileAccess.ReadWrite); Can someone help…
All Blond
  • 1,243
  • 2
  • 8
  • 4
120
votes
7 answers

Difference between stream processing and message processing

What is the basic difference between stream processing and traditional message processing? As people say that kafka is good choice for stream processing but essentially kafka is a messaging framework similar to ActivMQ, RabbitMQ etc. Why do we…
TechEnthusiast
  • 1,795
  • 2
  • 17
  • 32
116
votes
1 answer

How to clear ostringstream

ostringstream s; s << "123"; cout << s.str().c_str() << endl; // how to clear ostringstream here? s << "456"; cout << s.str().c_str() << endl; Output is: 123 123456 I need: 123 456 How can I reset ostringstream to get desired output?
Alex F
  • 42,307
  • 41
  • 144
  • 212
114
votes
9 answers

What is the purpose of Serialization in Java?

I have read quite a number of articles on Serialization and how it is so nice and great but none of the arguments were convincing enough. I am wondering if someone can really tell me what is it that we can really achieve by serializing a class?
m_a_khan
  • 1,511
  • 4
  • 13
  • 12
113
votes
1 answer

Open an IO stream from a local file or url

I know there are libs in other languages that can take a string that contains either a path to a local file or a url and open it as a readable IO stream. Is there an easy way to do this in ruby?
csexton
  • 24,061
  • 15
  • 54
  • 57
111
votes
13 answers

Reading large text files with streams in C#

I've got the lovely task of working out how to handle large files being loaded into our application's script editor (it's like VBA for our internal product for quick macros). Most files are about 300-400 KB which is fine loading. But when they go…
Nicole Lee
  • 1,133
  • 2
  • 8
  • 4
111
votes
4 answers

How does std::flush work?

Can someone please explain (preferably using plain english) how std::flush works? What is it? When would you flush a stream? Why is it important? Thank you.
Dasaru
  • 2,828
  • 5
  • 25
  • 25
110
votes
7 answers

How to save/restore serializable object to/from file?

I have a list of objects and I need to save that somewhere in my computer. I have read some forums and I know that the object has to be Serializable. But it would be nice if I can get an example. For example if I have the…
Tono Nam
  • 34,064
  • 78
  • 298
  • 470
107
votes
8 answers

Difference between java.io.PrintWriter and java.io.BufferedWriter?

Please look through code below: // A.class File file = new File("blah.txt"); FileWriter fileWriter = new FileWriter(file); PrintWriter printWriter = new PrintWriter(fileWriter); // B.class File file = new File("blah.txt"); FileWriter fileWriter =…
i2ijeya
  • 15,952
  • 18
  • 63
  • 72
106
votes
16 answers

Download content video from video stream with a path of .TS or .m3u8 file through actual code so i can make chrome extension

Videos on most sites make use of progressive downloading, which means that the video is downloaded to my computer, and easy to trace. There are lots of extensions out there to do this, and even in the dev-tools this is easily done. On certain…