I recently "searched" this idiom, and I'm thinking that I'm missing something or No. I've never used it in almost all Java code I have worked with "in the wild", for example (for example using the HTTP client and XML API) rather than some examples, data in a string or buffer Supports slowing down:
final LSOutput output; / / XML Luggage second place in the final LSSerializer serializer; Final document document; // post post; // HttpClient Post Request Last PipedOutputStream Source = New PipedOutputStream (); PipedInputStream Sync = New Pipe InStream (Source); // ... executor.execute (new runnab) (public zeros run) {output.setByteStream (source); serializer.write (doctor, output); {source.close ();} catches (iOException e) {new Runtime exception (e);}}}); Post.setRequestEntity (new InputStreamRequestEntity (sync)); Int Position = httpClient.executeMethod (post);
This code uses a UNIX-piping style technology to prevent multiple copies of XML data kept in memory. It uses the HTTP Post OutputStream and DOM Load / API so that an XML document can be released as the content of the HTTP request. As far as I can tell, the use of memory reduces a lot of extra code (just runnabal, piped intest, and some lines for pipes overputstream).
So, what is wrong with this idiom? If there is nothing wrong in this idiom, then why have not I seen it?
Edit: To make it clear, pipes interstream and pipes overoutstream boilerplate replace buffer-by-buffer copy that displays everywhere, and they also allow you to write processed data as well, They do not use the OS pipe to process incoming data.
From
:
Generally, data from a PipidInputStream object Thread is read and data is written on any other thread related to PipedOutputStream
It can be partially understood why it is not used more generally.
I believe another reason that many developers are not able to understand its purpose / benefits.
Comments
Post a Comment