streams

Best way to create word stream in C#

I'd like to be able to write something like the following. Can someone show me how to write a clean WordReader class in C#. (a word is [a-zA-Z]+) public List<string> GetSpecialWords(string text) { string word; List<string> specialWords = new List<string>(); using (WordReader wr = new WordReader(text)) ...

Setting the internal buffer used by a standard stream (pubsetbuf)

I'm writing a subroutine that needs to write data to an existing buffer, and I would like to use the stringstream class to facilitate the formatting of the data. Initially, I used the following code to copy the contents of the stream into the buffer, but would like to avoid this solution as it copies too much data. #include <sstream> #...

Anonymous stream in c

Can I make an anonymous stream in c? I don't want to create a new file on the file system, just have a stream that one function can fwrite to while the other can fread from it. Not c++, c. ...

Caching stream in c#

I have a bunch of files that are being read by another bunch of threads. Some parts of files get read multiple times using multiple file opens. I'd like to have a sort of caching file stream. If part of the file was read before, all subsequent reads would come from cache, otherwise file part would be read and content added to cache. F...

Multiple read from an InputStream at different rates

I'm about to load an online content (say an audio file). If I just open a connection to the remote file (for example by use of new URL().openStream()) and pass the remote InputStream to the audio player, it reads gradually from the network. If audio player library do not ask InputStream for more data, it reads nothing from the network, a...

Empty PHP SSH2 stream contents, even with stream_set_blocking?

I am working on a tool that reads an iptables configuration from a remote host over SSH2 using the PECL SSH2 extension. I am able to successfully make the connection to the host, authenticate, and execute commands. The trouble I am having is sometimes the stream doesn't contain any data. /** * Load the current firewall configuration ...

Something like print END << END; in C++?

Is there anyway to do something like PHP's print << END yadayadayada END; in C++? (multi-line, unescaped, easy-to-cut-and-paste stream insertion) ...

memorystream - stringstream, string, others?

hello, i am reading in a binary file via the usual c++/STL/iostream syntax. i am copying the whole content into an dynamically allocated char array and this works fine so far. but since i want to serve parts of the content as lines to another part of the program, i think it would be better/easier to stick to streams because i don't wan...

Java: Generalization possible between: streams, readers, char buffers, stringbuilder, ...?

Hello everyone! Background story: There are these Source and Result interfaces for XML. These are adapters between different XML technologies in Java. Instances of these classes represent DOM, SAX, JAXB, XML streams, XML events (and even more?). The question: So, is there something comparable for plain old strings? Some generalizatio...

How to check if stdin is still opened without blocking?

I need my program written in pure C to stop execution when stdin is closed. There is indefinite work done in program main cycle, and there is no way I can use blocking checks (like getc()) there (no data is supposed to arrive on stdin - it just stays opened for unknown time). I intend to use described functionality in realization of ne...

Close a FILE pointer without closing the underlying file descriptor

By using fdopen(), fileno() it's possible to open streams with existing file descriptors. However the proper way to close a file, once you've opened it with a stream is to fclose() the FILE pointer. How can one close the stream, but retain the open file descriptor? This behaviour is akin to calling fflush() and then fileno(), and then n...

What can be the reason for Windows error ERROR_DISK_FULL (112) when opening a NTFS alternate data stream?

My application writes some bytes of data to an alternate data stream. This works fine on all but one machine (Windows Server 2003 SP2). Instead, CreateFile returns ERROR_DISK_FULL when I try to create an alternate data stream (on the root directory). I don't find the reason for this result, because... There's plenty of space on that d...

How to play MP3 streams which are received by Silverlight from WCF?

How to play MP3 streams in silverlight 3? (streams which are received by Silverlight from WCF) ...

Better way to determine length of a std::istream?

Is there a better way to determine the length of an std::istream than the following: std::istream* pcStream = GetSomeStream(); pcStream->seekg(0, ios::end); unsigned int uiLength = pcStream->tellg(); It just seems really wasteful to have to seek to the end of the stream and then seek back to the original position, especially if the st...

Trouble using XmlTextWriter with MemoryStreams

I'm having trouble getting a memory stream and a XML text writer class to work together properly. Context.Reponse.BufferOutput=true; Context.Response.ContentType = "application/xml"; stmOutput = new MemoryStream(); Output = new XmlTextWriter(stmOutput, Encoding.ASCII); Output.WriteStartDocument(); Output.WriteStartElement("MyTag"); Outp...

How do I "fork" a Stream in .NET?

As discussed before, when a BinaryReader or BinaryWriter gets closed, its underlying Stream get closed as well (aargh). Consider this situation: a routine R is passed a MemoryStream, say M; I would like to write some stuff to M and then pass it to another routine for more processing (not necessarily writing). For convenience, I'd like t...

How to read a value with operator>> but no default constructor to the value ?

template <class T> T Read () { T t; cin >> t; if (cin.fail()) { // ... } return t; } This generic code read value of type T with some additional error handling. It relies on having operator>> that can parse T, and in this way it is extensible to new types. What I didn't realize is that it relies on T having a default co...

Java ProcessBuilder: external process hangs

I'm using Java's ProcessBuilder class to run an external process. The process should not terminate before the Java program does; it must stay alive in command/response mode. I know that the process streams may easily 'jam' if neglected, so I've done the following: The program reads the process's combined output and error streams in a "r...

Chrome saving streamed file as .gz

I have been banging my head against the wall with this odd behaviour on Chrome I have files stored encrypted on disk in an unnamed, unordered state. when the files are downloaded by the user, the client is redirected to a download handlers (.ashx) the data is loaded into a stream, decrypted and sent to the client. Now this has worked fi...

Adding tags to textwriter?

Hai how to add a tag in a start and tag in end tag textwriter? Thanx ...