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
104
votes
6 answers

HTTP requests with file_get_contents, getting the response code

I'm trying to use file_get_contents together with stream_context_create to make POST requests. My code so far: $options = array('http' => array( 'method' => 'POST', 'content' => $data, 'header' => …
georg
  • 211,518
  • 52
  • 313
  • 390
103
votes
10 answers

Play audio from a stream using C#

Is there a way in C# to play audio (for example, MP3) direcly from a System.IO.Stream that for instance was returend from a WebRequest without saving the data temporarily to the disk? Solution with NAudio With the help of NAudio 1.3 it is possible…
Martin
  • 10,738
  • 14
  • 59
  • 67
101
votes
3 answers

Java Process with Input/Output Stream

I have the following code example below. Whereby you can enter a command to the bash shell i.e. echo test and have the result echo'd back. However, after the first read. Other output streams don't work? Why is this or am I doing something wrong? My…
James moore
  • 1,245
  • 4
  • 13
  • 15
101
votes
7 answers

Node.js Piping the same readable stream into multiple (writable) targets

I need to run two commands in series that need to read data from the same stream. After piping a stream into another the buffer is emptied so i can't read data from that stream again so this doesn't work: var spawn =…
Maroshii
  • 3,937
  • 4
  • 23
  • 29
100
votes
4 answers

How to process a file in PowerShell line-by-line as a stream

I'm working with some multi-gigabyte text files and want to do some stream processing on them using PowerShell. It's simple stuff, just parsing each line and pulling out some data, then storing it in a database. Unfortunately, get-content | %{…
scobi
  • 14,252
  • 13
  • 80
  • 114
99
votes
13 answers

How to convert a Reader to InputStream and a Writer to OutputStream?

Is there an easy way to avoid dealing with text encoding problems?
Andrei Savu
  • 8,525
  • 7
  • 46
  • 53
96
votes
7 answers

How to read entire stream into a std::string?

I'm trying to read an entire stream (multiple lines) into a string. I'm using this code, and it works, but it's offending my sense of style... Surely there's an easier way? Maybe using stringstreams? void Obj::loadFromStream(std::istream &…
Roddy
  • 66,617
  • 42
  • 165
  • 277
95
votes
6 answers

Can I stream a file upload to S3 without a content-length header?

I'm working on a machine with limited memory, and I'd like to upload a dynamically generated (not-from-disk) file in a streaming manner to S3. In other words, I don't know the file size when I start the upload, but I'll know it by the end. …
Tyler
  • 28,498
  • 11
  • 90
  • 106
95
votes
3 answers

Should I log messages to stderr or stdout?

I have a program I'm writing that I want to write a custom logging facility for (e.g. diagnostic, notice, warning, error). Should I be using the stdout or the stderr stream to do this? It is an interpreter of sorts and the user can ask it to print…
user193476
93
votes
5 answers

Most efficient way to create InputStream from OutputStream

This page: http://blog.ostermiller.org/convert-java-outputstream-inputstream describes how to create an InputStream from OutputStream: new ByteArrayInputStream(out.toByteArray()) Other alternatives are to use PipedStreams and new threads which is…
Vagif Verdi
  • 4,816
  • 1
  • 26
  • 31
90
votes
1 answer

What's the difference between end and finish events in Node streams

Node.js streams triggers both end and finish events. What's the difference between both?
Simon Boudrias
  • 42,953
  • 16
  • 99
  • 134
89
votes
12 answers

Read a file/URL line-by-line in Swift

I am trying to read a file given in an NSURL and load it into an array, with items separated by a newline character \n. Here is the way I've done it so far: var possList: NSString? = NSString.stringWithContentsOfURL(filePath.URL) as? NSString if…
Matt
  • 2,576
  • 6
  • 34
  • 52
88
votes
9 answers

How to get a MemoryStream from a Stream in .NET?

I have the following constructor method which opens a MemoryStream from a file path: MemoryStream _ms; public MyClass(string filePath) { byte[] docBytes = File.ReadAllBytes(filePath); _ms = new MemoryStream(); _ms.Write(docBytes, 0,…
fearofawhackplanet
  • 52,166
  • 53
  • 160
  • 253
87
votes
13 answers

How to redirect ProcessBuilder's output to a string?

I am using the following code to start a process builder.I want to know how can I redirect its output to a String. ProcessBuilder pb = new ProcessBuilder( System.getProperty("user.dir") + "/src/generate_list.sh", filename); Process p =…
Ankesh Anand
  • 1,695
  • 2
  • 16
  • 24
85
votes
5 answers

What does stream mean? What are its characteristics?

C++ and C# both use the word stream to name many classes. C++: iostream, istream, ostream, stringstream, ostream_iterator, istream_iterator... C#: Stream, FileStream,MemoryStream, BufferedStream... So it made me curious to know, what does stream…
Kashif
  • 2,926
  • 4
  • 20
  • 20