Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Jan Burse Newsgroups: comp.lang.java.programmer Subject: Re: Fav. Memory Stream Impl. Date: Mon, 28 Nov 2011 00:13:00 +0100 Organization: albasani.net Lines: 88 Message-ID: References: <4ed0101b$0$282$14726298@news.sunsite.dk> <9jflnkFnrgU1@mid.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net UyCxRbIFRcV1IVS+i1wbW4cznOzbR2YyhZaVAktNt5YQlOpiRSYObOv8tpLUxaxuTIfRSf2m1IkH/T26RN5puEk30gakp8TFE4LSwyhU/stEpvVCSMMUHmmBtjFMK2g5 NNTP-Posting-Date: Sun, 27 Nov 2011 23:13:00 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="VLpDRfM3tyN0oXAACrCd/wyub+haWxOqD64cvnPeon1T6g18p7zI/OGWE8OD0tamAkYrBzaIVw2x3xu6iulmOdwVwS/Sw9rTJulvuSOtZpTVv+uDW+CifjgcuMh1r5Pl"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0.1) Gecko/20111121 Firefox/8.0.1 SeaMonkey/2.5 In-Reply-To: <9jflnkFnrgU1@mid.individual.net> Cancel-Lock: sha1:BY7RGnhtw4hDl9vpQfuiX1uRP5o= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10282 Robert Klemme schrieb: > > http://docs.oracle.com/javase/6/docs/api/java/io/PipedInputStream.html > http://docs.oracle.com/javase/6/docs/api/java/io/PipedOutputStream.html > > Still, why do you want to do this? What problem are you trying to > solve? I'm not convinced that it is a good idea - especially when using > unbounded buffers. A pipe is not a memory stream. In a pipe the reader does read where the writer does write. But I don't have this requirement. The only requirement I have, is that I can use the memory streams in place of >>TEMPORARY FILES<<. Whereas >>TEMPORARY FILES<< have a name and usually exist on some media. The memory streams should not exist on some media, except in the memory. But they should share with >>TEMPORARY FILES<< multiple readers / writers and positioninng. Since I can use a >>TEMPORARY FILES<< name and open a RandomAccessFile with it. So basically in my application I would like to have some class, call it MemoryStream. And It would like to be able to instantiate it. And this instance serves than as a kind of a file name. So this instance I should be able to use where I normally would use the >>TEMPORARY FILES<< name. The only places that come to my mind are: - creating an input stream from a file name, should then work from a memory stream instance. - creating an output stream from a file name, should then work from a memory stream instance. - creating a random acccess file from a file name, should then work from a memory stream instance. What the memory stream instance will have in common with a >>TEMPORARY FILES<< name, is that it will go away when the application closes. So they are very similar to >>TEMPORARY FILES<< with the option delete on close. Also I would like to be able to use the same memory stream to open input streams, output streams, random access files, as many as I want. This is also provided by >>TEMPORARY FiLES<<, once a >>TEMPORARY FILES<< name is established, it can be used for all kinds of stuff. Here is a little example: A large clip board: This could be realized by a temporary file. When you make the copy operation, you simply write the copied content into the temporary file. When you make the past operation you reopen the temporary file and read the content that should be pasted from it. The above could be realized by even passing the >>TEMPORARY FILES<< name around in the system clipboard, so that the copy paste works across applications. Provided that the applications understand the content type. But memory streams cannot passed around like this. Here is the difference to >>TEMPORARY FILES<<. In their simple implementation they are confined to the application that created them. Of course we could extend them and provide some RMI extension of them, or what ever, so that the a memory stream references becomes mobile. Or we could implement them in special shared memory of the operating system, so that a direct shared access from multiple applications is possible. This mobility and shared access across multiple application, which is a property of >>TEMPORARY FILES<<, is not required for the memory streams I am looking for. So I guess if my grandmother could program as she can knit pullovers for me, she might do a memory stream class for me. But unfortunately she knows only COBOL and I am looking for a Java library. But she assured me that something like this must exist on the web, and that I don't need to go into lengths to code it by myself. So she told me: It's not difficult, but why reinvent the wheel? Bye