Skip to main content

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.

4741 votes
66 answers
2.7m views

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 ...
Johnny Maelstrom's user avatar
626 votes
9 answers
642k views

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 ...
Roman Podlinov's user avatar
573 votes
13 answers
383k views

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's user avatar
  • 6,950
102 votes
3 answers
223k views

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 ...
James moore's user avatar
  • 1,255
516 votes
24 answers
504k views

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, ...
Matt Sheppard's user avatar
161 votes
16 answers
391k views

Java : How to determine the correct charset encoding of a stream

With reference to the following thread: Java App : Unable to read iso-8859-1 encoded file correctly What is the best way to programatically determine the correct charset encoding of an inputstream/...
Joel's user avatar
  • 29.9k
28 votes
3 answers
31k views

Display data streamed from a Flask view as it updates

I have a view that generates data and streams it in real time. I can't figure out how to send this data to a variable that I can use in my HTML template. My current solution just outputs the data to ...
JeffThompson's user avatar
  • 1,590
888 votes
10 answers
1.1m views

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(...
Loadman's user avatar
  • 9,027
192 votes
9 answers
190k views

Can I redirect the stdout into some sort of string buffer?

I'm using python's ftplib to write a small FTP client, but some of the functions in the package don't return string output, but print to stdout. I want to redirect stdout to an object which I'll be ...
Avihu Turzion's user avatar
385 votes
12 answers
710k views

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 ...
xaav's user avatar
  • 7,906
114 votes
13 answers
254k views

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-...
Nicole Lee's user avatar
  • 1,163
111 votes
7 answers
263k views

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 ...
Tono Nam's user avatar
  • 35.5k
1028 votes
14 answers
852k views

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's user avatar
  • 70.8k
646 votes
23 answers
1.0m views

Fastest way to check if a file exists using standard C++/C++11,14,17/C?

I would like to find the fastest way to check if a file exists in standard C++11, 14, 17, or C. I have thousands of files and before doing something on them I need to check if all of them exist. What ...
Vincent's user avatar
  • 59.6k
53 votes
4 answers
56k views

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? ...
yotamoo's user avatar
  • 5,404

15 30 50 per page
1
2 3 4 5
126