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.

14148 questions
4332
votes
60 answers

How do I read / convert an InputStream into a String in Java?

If you have a java.io.InputStream object, how should you process that object and produce a String? Suppose I have an InputStream that contains text data, and I want to convert it to a String, so for example I can write that to a log file. What is…
Johnny Maelstrom
  • 44,165
  • 5
  • 19
  • 18
854
votes
12 answers

How do I generate a stream from a string?

I need to write a unit test for a method that takes a stream which comes from a text file. I would like to do do something like this: Stream s = GenerateStreamFromString("a,b \n c,d");
Omu
  • 64,955
  • 87
  • 259
  • 396
829
votes
5 answers

How do I convert struct System.Byte byte[] to a System.IO.Stream object in C#?

How do I convert struct System.Byte byte[] to a System.IO.Stream object in C#?
Mehdi Hadeli
  • 8,499
  • 2
  • 18
  • 17
758
votes
10 answers

How do I save a stream to a file in C#?

I have a StreamReader object that I initialized with a stream, now I want to save this stream to disk (the stream may be a .gif or .jpg or .pdf). Existing Code: StreamReader sr = new StreamReader(myOtherObject.InputStream); I need to save this to…
Loadman
  • 7,727
  • 3
  • 15
  • 3
605
votes
5 answers

Get an OutputStream into a String

What's the best way to pipe the output from an java.io.OutputStream to a String in Java? Say I have the method: writeToStream(Object o, OutputStream out) Which writes certain data from the object to the given stream. However, I want to get this…
Adrian Mouat
  • 38,986
  • 15
  • 98
  • 99
532
votes
13 answers

How do I copy the contents of one stream to another?

What is the best way to copy the contents of one stream to another? Is there a standard utility method for this?
Anton
  • 6,450
  • 11
  • 28
  • 26
519
votes
20 answers

Fastest way to check if a file exist using standard C++/C++11/C?

I would like to find the fastest way to check if a file exist in standard C++11, C++, or C. I have thousands of files and before doing something on them I need to check if all of them exist. What can I write instead of /* SOMETHING */ in the…
Vincent
  • 50,257
  • 51
  • 171
  • 339
468
votes
23 answers

Easy way to write contents of a Java InputStream to an OutputStream

I was surprised to find today that I couldn't track down any simple way to write the contents of an InputStream to an OutputStream in Java. Obviously, the byte buffer code isn't difficult to write, but I suspect I'm just missing something which…
Matt Sheppard
  • 111,039
  • 46
  • 105
  • 128
466
votes
6 answers

Download large file in python with requests

Requests is a really nice library. I'd like to use it for downloading big files (>1GB). The problem is it's not possible to keep whole file in memory; I need to read it in chunks. And this is a problem with the following code: import requests def…
Roman Podlinov
  • 19,179
  • 7
  • 37
  • 56
357
votes
12 answers

Download File to server from URL

Well, this one seems quite simple, and it is. All you have to do to download a file to your server is: file_put_contents("Tmpfile.zip", file_get_contents("http://someurl/file.zip")); Only there is one problem. What if you have a large file, like…
xaav
  • 7,348
  • 7
  • 27
  • 42
308
votes
9 answers

Save and load MemoryStream to/from a file

I am serializing an structure into a MemoryStream and I want to save and load the serialized structure. So, How to Save a MemoryStream into a file and also load it back from file?
Mahdi Ghiasi
  • 13,093
  • 16
  • 63
  • 116
284
votes
6 answers

How do I turn a String into a InputStreamReader in java?

How can I transform a String value into an InputStreamReader?
Yossale
  • 13,197
  • 18
  • 76
  • 102
248
votes
8 answers

Difference between fprintf, printf and sprintf?

Can anyone explain in simple English about the differences between printf, fprintf, and sprintf with examples? What stream is it in? I'm really confused between the three of these while reading about "File Handling in C".
Vishwanath Dalvi
  • 31,604
  • 36
  • 115
  • 146
203
votes
12 answers

How to create streams from string in Node.Js?

I am using a library, ya-csv, that expects either a file or a stream as input, but I have a string. How do I convert that string into a stream in Node?
pathikrit
  • 29,060
  • 33
  • 127
  • 206
194
votes
15 answers

Can you explain the concept of streams?

I understand that a stream is a representation of a sequence of bytes. Each stream provides means for reading and writing bytes to its given backing store. But what is the point of the stream? Why isn't the backing store itself what we interact…
Rob Sobers
  • 19,173
  • 22
  • 78
  • 107
1
2 3
99 100