java.io has many different I/O streams, (FileInputStream, FileOutputStream, FileReader, FileWriter, BufferedStreams... etc.) and I am confused in determining the differences between them. What are some examples where one stream type is preferred over another, and what are the real differences between them?
...
I'm working on an iPhone project that needs to receive data from a PHP script during execution. My first thought was to use sockets/streams on either end to connect the two, but I am having trouble finding information on how to do this from the iPhone side.
Has anyone been down this path that could point me towards some useful resources...
What are the underlying constructs of the concept known as a "stream"? How do they work internally?
How does a memory stream work?
How does a file stream work?
Edit - From the answers I'm guessing that each type of stream is implemented differently, but the core concept is a sequence of bytes controlled and modelled by a class or a s...
The code below has a method that sets the member field 'x' using the getline() function.
I noticed that if I use cin before calling that method, my program would hang the next time I reach the line getline(cin, rangeInput).
Since getline() is using cin, is that why it is causing the program to hang if I have previously used cin? What sh...
I need to attach a pdf I created in memory to an email. Attachments can take a stream. So I believe I need to convert a iTextSharp Document object to stream. How can I do that?
I tried serializing the Document object to a stream but it is not "marked as serializable".
Thanks
...
Hi,
I have a log file that continually logs short lines. I need to develop a service that reacts (or polls, or listens to) to new lines added to that file, a sort of unix' tail program, so that my service is always up to date reguarding the file.
I don't think that opening a read stream and keeping it opened is a good idea. Maybe I sho...
In Flex 3/AS 3, what would be a good way to check if a remote file exists?
I'm thinking in PHP ways where you'd try to "fopen" a remote path (like "http://example.com/somefile.exe"), and see if it works or not. I'm not asking to just download all of the file, I just want to know if the file is there (and accessible).
...
There is a fairly common pattern used in .NET to test for the capabilities of a class. Here I'll use the Stream class as an example, but the issue applies to all classes that use this pattern.
The pattern is to supply a boolean property called CanXXX to indicate that capability XXX is available on the class. For example, the Stream cl...
I hardly find a good resource about the subject. Almost all books and websites I know give a simple introduction about streams in C++ and that's it!
Would you recommend a good book or tutorial to learn more about standard streams in C++ ?
...
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 able to read the output from.
I know stdout can be redirected into any regular file with:
stdout = open("file", "a")
But I prefer a metho...
I want to parse user input in a streamReader. My code is:
string txt = txtin.text ; //<~~ txtin is something like root:x:1:1....
using (TextReader reader = new TextReader( txt))
{
string line = "";
while ((line = reader.ReadLine()) != null)
{
string userName = line.Substring(0, line.IndexOf(':'));
}
}
I get ...
Am I right that you'd only need a using() for the outermost stream if you're doing e.g
MemoryStream mstr = new MemoryStream();
using(StreamWriter w = new StreamWriter(mstr)) {
....
}
As disposing the StreamWriter should also dispose/close the underlying stream, there's no need to do this ?:
using(MemoryStream mstr = new MemoryS...
This page: http://ostermiller.org/convert_java_outputstream_inputstream.html
describes how to create an InputStream from OutputStream:
new ByteArrayInputStream(out.toByteArray())
Other alternatives are to use PipedStreams and new threads which is cumbersome.
I do not like the idea of copying many megabytes to new in memory Bytes a...
In java.io.FileInputStream, there is a method int read(Byte[] buffer,int offset,int numBytes); how we can use this function - is there any difference between this method and read(byte[] buffer)?
...
I'm still pretty new to Rails and need your help: I have been creating a social fitness analytics site (zednine.com) that has an activity stream that lists workouts posted on the site. Several pages currently show the 10 most recently updated workouts. I'd like to add a link at the bottom to "Older workouts." On click, this should show t...
Is is possible to try to read from a stream but do not change the stream itself (and return bool whether it was a success)?
template <typename T> bool SilentRead (stringstream& s, T& value) {
stringstream tmp = s;
tmp >> value;
return tmp;
}
This doesn't work because stringstream doesn't have public copy constructor.
How t...
I want to write a simple web proxy, for exercise. Here's the code I have so far:
def g = new Proxy()
g.serverPort = 9000
println "starting"
g.eachClient { Socket client ->
println "got a client"
try {
client.withStreams { input,output ->
String text = input.text
println "received $text from clien...
I'm running into an issue where reading from a HttpResponseStream fails because the StreamReader that I'm wrapping around in reads faster that the Response Stream gets the actual response. I'm retrieving a reasonably small sized file (around 60k) but the Parser which processes the response into an actual object fails because it hits an ...
Hi,
I'm making Braid in Java. If you rewind the time, the sound plays backward
Does somebody now how to play a wav backward? Maybe with a stream with something like previous()???
On the site of braid can you see what I mean.
Solved!!: See my own post!!!!!!
Thanks
...
This is the C# code. Can you help me translate this to powershell?
private static void Main(string[] args)
{
byte[] buffer = (byte[]) Registry.LocalMachine.OpenSubKey(@"HARDWARE\ACPI\DSDT\HP____\8510x\00010000").GetValue("00000000");
if (File.Exists("8510x.orig"))
{
Console.WriteLine("File 8510x.orig already exists...