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
85
votes
3 answers

What is the mask in a WebSocket frame?

I am working on a websocket implementation and do not know what the sense of a mask is in a frame. Could somebody explain me what it does and why it is recommend? 0 1 2 3 0 1 2 3 4 5 6 7 8 9…
bodokaiser
  • 15,122
  • 22
  • 97
  • 140
85
votes
6 answers

ReadAllLines for a Stream object?

There exists a File.ReadAllLines but not a Stream.ReadAllLines. using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Test_Resources.Resources.Accounts.txt")) using (StreamReader reader = new StreamReader(stream)) { …
Ryan Peschel
  • 11,087
  • 19
  • 74
  • 136
83
votes
4 answers

Memory Stream in Java

I am looking for a memory stream implementation in Java. The implementation should be roughly modeled after the .NET memory stream implementation. Basically I would like to have a class MemoryStream which has to factory methods: class MemoryStream…
user502187
82
votes
7 answers

How to read/write files in .Net Core?

What are the options to read/write files in .Net Core? I am working on my first .Net Core app and looking for File.Read*/File.Write* functions (System.IO from .Net) alternatives.
Ankit
  • 2,448
  • 3
  • 20
  • 33
80
votes
4 answers

How to create an instance of System.IO.Stream stream

How to create an instance of System.IO.Stream stream. One of my function receives System.IO.Stream stream as parameter and write some thing to it. So how can I create a new instance of the same and pass it to the function ?
Rauf
  • 12,326
  • 20
  • 77
  • 126
78
votes
3 answers

Kotlin Coroutines: Channel vs Flow

I'm recently studying and reading a lot about Flow and Kotlin Coroutines. But I still get confused about when I should use Flow and when I should use Channel. At the beginning it looked more simple. Working with hot streams of data? Channel. Cold…
Francisco Durdin Garcia
  • 12,540
  • 9
  • 53
  • 95
77
votes
6 answers

An elegant way to consume (all bytes of a) BinaryReader?

Is there an elegant to emulate the StreamReader.ReadToEnd method with BinaryReader? Perhaps to put all the bytes into a byte array? I do this: read1.ReadBytes((int)read1.BaseStream.Length); ...but there must be a better way.
SamFisher83
  • 3,937
  • 9
  • 39
  • 52
69
votes
4 answers

Why is Files.lines (and similar Streams) not automatically closed?

The javadoc for Stream states: Streams have a BaseStream.close() method and implement AutoCloseable, but nearly all stream instances do not actually need to be closed after use. Generally, only streams whose source is an IO channel (such as those…
MikeFHay
  • 8,562
  • 4
  • 31
  • 52
68
votes
4 answers

ASP.Net MVC - Read File from HttpPostedFileBase without save

I am uploading the file by using file upload option. And i am directly send this file from View to Controller in POST method like, [HttpPost] public ActionResult Page2(FormCollection objCollection) { HttpPostedFileBase file =…
Manikandan Sethuraju
  • 2,873
  • 10
  • 29
  • 48
68
votes
10 answers

Android - Store inputstream in file

I am retrieveing an XML feed from a url and then parsing it. What I need to do is also store that internally to the phone so that when there is no internet connection it can parse the saved option rather than the live one. The problem I am facing is…
Dobes
  • 683
  • 1
  • 5
  • 4
66
votes
5 answers

When or if to Dispose HttpResponseMessage when calling ReadAsStreamAsync?

I am using the System.Net.Http.HttpClient to do some client-side HTTP communication. I've got all of the HTTP in one spot, abstracted away from the rest of the code. In one instance I want to read the response content as a stream, but the consumer…
dkackman
  • 15,179
  • 13
  • 69
  • 123
66
votes
6 answers

Capture both stdout and stderr in Bash

I know this syntax var=`myscript.sh` or var=$(myscript.sh) Will capture the result (stdout) of myscript.sh into var. I could redirect stderr into stdout if I wanted to capture both. How to save each of them to separate variables? My use case here…
djechlin
  • 59,258
  • 35
  • 162
  • 290
64
votes
4 answers

Process a continuous stream of JSON

The (now defunct) page http://stream.twitter.com/1/statuses/sample.json used to return a continuous and endless stream of JSON data. I'd like to process it using jQuery (or JavaScript, but preferably jQuery) inside my own web page to be able to…
kettlepot
  • 10,574
  • 28
  • 71
  • 100
64
votes
2 answers

Events vs Streams vs Observables vs Async Iterators

Currently, the only stable way to process a series of async results in JavaScript is using the event system. However, three alternatives are being developed: Streams: https://streams.spec.whatwg.org Observables:…
Daniel Herr
  • 19,083
  • 6
  • 44
  • 61
64
votes
3 answers

Buffer entire file in memory with Node.js

I have a relatively small file (some hundreds of kilobytes) that I want to be in memory for direct access for the entire execution of the code. I don't know exactly the internals of Node.js, so I'm asking if a fs open is enough or I have to read all…
Leonardo Rossi
  • 2,922
  • 2
  • 20
  • 28