streams

StreamReader returning another char

I'm trying to read the content of a file with a StreamReader, that receives a FileStream. The file has some spaces inside (char 32) and the StreamReader is reading them as 0 (char 48). The screenshot shows the FileStream buffer and the StreamReader buffer. Both have the value 32, but when I call Read(), it returns 48. Am I missing someth...

SCJP Book, IO section: Is this a typo or is there a reason it would look like this?

My question is about line (edit: 19), where the new PrintWriter is created with the constructor taking the FileWriter fw as a parameter. I don't understand the use of chaining the BufferedWriter bw to FileWriter if it isn't used later on in the actual writing. Can Java apply chaining in a way that bw still somehow affects the rest of the...

How do I make a daemon into a stream in PHP

I have a daemon (written in C, but I assume it does not really matter) which outputs messages with printf, and can get input and do stuff with this input (again, not really important what, but he sends those messages to a different machine to be saved there in the DB). My question, how can I make this daemon to be a stream in PHP, so ...

Why is the same CURL code failing on one server and yet works on the other one?

The code attempts to grab a test page for example Yahoo.com in this case. I am outputting the var_dump http://jinimatics.com/test.php (this works) http://jinimetrix.com/test.php (this does not) (Curl is installed on both servers along with fairy recent Lamp Stack) ...

What kind of cool stuff can I do with PHP's streams?

It seems that PHP's streams aren't used much, but they appear to be very powerful. Does anyone have an example of implementing a stream to do something that would be clunky otherwise? I don't mean doing stuff like file_get_contents('http://google.com');, I mean implementing your own streams. ...

Easiest way to combine a dataset and other data in a single file?

I have a dataset in C# which I can serialise using dataset.WriteXml(filename); but I want the file to contain other data as well (essentially some meta data about the dataset). I could add another table to the dataset which contained the metadata, but I'd prefer to keep it separate, if at all possible. Essentially I think I want to cre...

Functional programming approach for Java's input/output streams

I'm using Java's DataInputStream with scala to parse some simple binary file (which is very bad exprerience due to the lack of unsigned types, even in scala, but that's a different story). However I find myself forced to use mutable data structure, since Java's streams are inherently state preserving entities. What's a good design to w...

C++ convert formatted string to a stream

Hi All, I'm using VS2008 C++. As I understand it there is no way to pass something like this in a C++ stream : (without using external libraries) "number " << i <------ when i is an integer. So I was looking for a better way to do this, and I all I could come up with is create a string using : char fullstring = new char[10]; spr...

Which is faster: Cloning or using Streams?

In Java, which is faster: Cloning an Object, then passing it to multiple listeners assuming the cloned object contains nothing more complicated than nested arrays, primitives and Strings Using Streams to pass data through from one object to another? ...

Should I always wrap an InputStream as BufferedInputStream?

Does it make sense to always wrap an InputStream as BufferedInputStream, when I know whether the given InputStream is something other than buffered? For e.g: InputStream is = API.getFromSomewhere() if(!(is instanceof BufferedInputStream)) return new BufferedInputStream(is); return is; ...

Objective-C Socket Streams "Bad File Descriptor" (IPhone)

I'm trying to create a simple IRC client, purely for fun and to try and learn a bit more about socket programming in objective C. So I've looked at some sample code and I have no idea why I can't seem to send or receive message upon connecting. Firstly I connect to the server using the following code: if (![urlString isEqualToString:...

C++ - Implementing my own stream

Hello! My problem can be described the following way: I have some data which actually is an array and could be represented as char* data with some size I also have some legacy code (function) that takes some abstract std::istream object as a param and uses that stream to retrieve data to operate. So, my question is the following - wha...

C++ - Where to throw exception?

Hello! I have some kind of an ideological question, so: Suppose I have some templated function template <typename Stream> void Foo(Stream& stream, Object& object) { ... } which does something with this object and the stream (for example, serializes that object to the stream or something like that). Let's say I also add some plain wr...

Java Input/Output streams for unnamed pipes created in native code?

Is there a way to easily create Java Input/Output streams for unnamed pipes created in native code? Motivation: I need my own implementation of the Process class. The native code spawns me a new process with subprocess' IO streams redirected to unnamed pipes. Problem: The file descriptors for correct ends of those pipes make their way ...

How can you tell the source of the data when using the Stream.BeginRead Method?

When using the Stream.BeginRead Method, and you are reading from a stream into a memory, how is it determined where you are reading the data from? See: http://msdn.microsoft.com/en-us/library/system.io.stream.beginread.aspx In the list of parameters, I do not see one that tells where the data is being read from: Parameters buffer Ty...

running shell commands with gnu clisp

I'm trying to create a "system" command for clisp that works like this (setq result (system "pwd")) ;;now result is equal to /my/path/here I have something like this: (defun system (cmd) (ext:run-program :output :stream)) But, I am not sure how to transform a stream into a string. I've reviewed the hyperspec and google more than ...

VOIP wake up in iOS4

has anyone gotten VIOP sockets to wake up the app on receipt of new data? I have been able to do the following: set plist flag to voip set the streams as voip type the sockets remain open when the application moves into the background but messages are not processed. According to apple the correct behaviour is " If new data arrives wh...

operator << overload c++

how can i overload "<<" operator (for cout) so i could do "cout" to a class k ...

What is the proper way to manage large IStreams?

I am writing a C# class library to transfer large volumes of data through COM automation using an IStream. It uses the CreateStreamOnHGlobal API call to create the stream, and the methods within System.Runtime.InteropServices.COMTypes.IStream to work with it. My question is, when transferring large volumes of data, what is the best way...

Scheme, When to use Symbols instead of Strings?

I apologize in advance for my primitive english; i will try my best to avoid grammatical errors and such. Two weeks ago i decided to freshen my knowledge of Scheme (and its enlightnings) whilst implementing some math material i got between hands, specifically, Regular Languages from a course on Automata theory and Computation in which ...