streams

Strange problem with Streams

I am receiving an XML via an HttpPost to my service, and I want to log the received value for debugging purposes. First I deserialize it into an entity like this: XmlSerializer s = new XmlSerializer(typeof(TransactionResults)); TransactionResults t = (TransactionResults)s.Deserialize(stream); This, of course, moves the stream to the...

Best way to pipe data from one Inputput Stream to multiple Output Streams

A PipedInputStream/PipedOutputStream connection works great when the data only needs to be piped to one output, but if multiple output streams are connected to one input stream, the data becomes fragmented across the different outputs. My current solution involves having a threaded "reader" that reads data from an InputStream and then w...

ObjectStream Crashes

Today I've got an problem with an ObjectStream (Input and also Output). I used the Input and OutputStream which came directly out of the socket. While initialising the streams my runs and runs and runs. With no error message. I got no error message. It seems that the constructor of the ObjectInputStream runs endless... Here is the code...

CFReadStreamRef, CFWriteStreamRef and multithreadinf issue.

Hi, I had the following situtation, I'm reading and parsing some packets from the network within a separated thread (not the main thread). After this, I'm trying to put them into a CFWriteStreamRef (created using CFStreamCreateBoundPair, in order to get a CFReadStreamRef that could be able to read the bytes from the writer stream) in a ...

reading primitives from file in C

Hi Folks, I am new to C, and want to read some data from a file. Actually, I find many reading functions, fgetc, fgets, etc.. But I don't know which one/combination is the best to read a file with the following format: 0 1500 100.50 1 200 9 2 150 10 I just need to save each row above into a struct with three data members. I...

How to preserve formatting for C++ streams?

I have the following code (simplified): ostringstream oss; oss << "Text "; oss << hex << uppercase; oss.width(8); oss.fill('0'); oss << var1 << " "; oss << var2 << " "; oss << dec << nouppercase; oss.width(1); oss << var3 << " another text." << endl; string result = oss.str(); // work with result... Where var1, var2 are unsigned...

Splitting byte array and putting it back together properly

How should I really go about implementing the following? I will have to handle a byte array that will contain text on several lines. The average size of the data is probably going to be around 10 kilobytes of data. After unspecified amount of lines there will be a line starting with special token ("FIRSTSTRING"). Later somewhere on the...

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 & stream) { std::string s; int p = stream.tellg(); // remember where we are stream.seekg...

array of streams in c sharp

Typically I declare streams inside of a using statement to ensure that the stream is properly disposed when I am done with it, and so that I don't mistakenly call it when I'm outside the using block. Some examples here: MSDN using Statement Reference How does one use a using statement with an array of streams? Would it be equivalent to...

Redirect a file stream into memory stream

Hey, I do have a program (call it "a.exe" for example) which reads its config from several files. can I write another program to redirect all file accesses of "a.exe" to another stream (console for example)? I don't have the code of "a.exe" but if I get the source code of a.exe, obviously I can change all the file accesses. but is ther...

Memory Stream in C++ using type declarations

Possible Duplicate: Are there binary memory streams in C++ Oops - http://stackoverflow.com/questions/1559254/are-there-binary-memory-streams-in-c ...

Is it possible to restrict/require certain capabilities in a Stream parameter?

I'm writing an application that creates catalogs of files. Currently the catalog information is stored in an XML file, but I'm trying to abstract the interface to a catalog to allow for other future storage mechanisms such as a single ZIP file, SQL server, or HTTP server. So rather than returning a file path the abstract Catalog class re...

Dispose a stream in a BizTalk pipeline component?

I'm fairly new to BizTalk and creating a custom pipeline component. I have seen code in examples that are similar to the following: public void Disassemble(IPipelineContext pContext, IBaseMessage pInMsg) { Stream originalDataStream = pInMsg.BodyPart.GetOriginalDataStream(); StreamReader strReader = new StreamReader(originalDat...

connect OutputStream with an InputStream

I'm experimenting with a little web framework and stumbled across an issue with streams. There are handler methods like Response get(HttpServletRequest). From the frameworks perspective the response should offer an input stream for the response body. The framework reads this streams and writes the data to the underlying OutputStream of t...

Stream of readLines

I'm attempting to create an infinite stream of strings from readLine calls: import java.io.{BufferedReader, InputStreamReader} val in = new BufferedReader(new InputStreamReader(System in)) val input: Stream[String] = Stream.cons(in readLine, input) But it appears that the readLine call isn't being called lazily. Immediately after ente...

How to print an object of unknown type

I have a templatized container class in C++ which is similar to a std::map (it's basically a thread-safe wrapper around the std::map). I'd like to write a member function which dumps information about the entries in the map. Obviously, however, I don't know the type of the objects in the map or their keys. The goal is to be able to ha...

How to speed-up loading of 15M integers from file stream?

Hello, I have an array of precomputed integers, it's fixed size of 15M values. I need to load these values at the program start. Currently it takes up to 2 mins to load, file size is ~130MB. Is it any way to speed-up loading. I'm free to change save process as well. std::array<int, 15000000> keys; std::string config = "config.dat"; /...

Why do I need two calls to stream CopyTo?

Hi all, I have the following method and for some reason the first call to Copy to seems to do nothing? Anyone know why? In input to the method is compressed and base64 can supply that method to if need. private byte[] GetFileChunk(string base64) { using ( MemoryStream compressedData = new MemoryStream(Convert.Fro...

Accessing Windows' special named folders in PHP fopen streams

Hi Everyone, http://en.wikipedia.org/wiki/Special_Folders I am having a problem with accessing a special folder in a fopen stream in php. Example $fp = fopen("%USERPROFILE%/Desktop/text.txt", 'wb'); fwrite($fp, $data); fclose($fp); I try this with sysinternals process monitor running to try and see what is actually happening and it...

Java String from InputStream

Possible Duplicates: How do I convert an InputStream to a String in Java? In Java how do a read an input stream in to a string? I have an InputSteam and need to simply get a single simple String with the complete contents. How is this done in Java? ...