Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Fav. Memory Stream Impl.

Reply
Thread Tools

Fav. Memory Stream Impl.

 
 
Jan Burse
Guest
Posts: n/a
 
      11-25-2011
Dear All,

Would be interested in a good memory stream
implementation. Requirement will be multiple
readers / writers and positioning.

Just found this code:

http://www.mikepaul.ca/index.php?opt...e-dev&Itemid=4
..Net style MemoryStream for Java/J2ME!
Thursday, 27 May 2010 22:52 | Written by Michael Paul

Although it has read / write and positioning,
I don't think it is thread safe. Any other
implementations around.

Maybe some operations that provide InputStream /
OutputStream factory methods.

But
 
Reply With Quote
 
 
 
 
markspace
Guest
Posts: n/a
 
      11-25-2011
On 11/25/2011 9:39 AM, Jan Burse wrote:
> Dear All,
>
> Would be interested in a good memory stream implementation.


What is a "memory stream?"

Java already has bounded and unbounded queues, in thread safe and
non-thread safe version. For special pruposes Java also has things like
memory buffers for logging.

What's the actual use model for this thing?

(Esp. for those of us who don't know anything about C#/.Net)

 
Reply With Quote
 
 
 
 
Jan Burse
Guest
Posts: n/a
 
      11-25-2011
markspace schrieb:
> For special pruposes Java also has things like memory buffers for logging.


Which classes? Part of JDK or some utility?
 
Reply With Quote
 
markspace
Guest
Posts: n/a
 
      11-25-2011
On 11/25/2011 11:59 AM, Jan Burse wrote:
> markspace schrieb:
>> For special pruposes Java also has things like memory buffers for
>> logging.

>
> Which classes? Part of JDK or some utility?



It wouldn't kill you to look through the Java API yourself, you know.
Specifically for the logger, since that's what you seem to be interested in:

<http://docs.oracle.com/javase/7/docs/api/java/util/logging/MemoryHandler.html>


 
Reply With Quote
 
Jan Burse
Guest
Posts: n/a
 
      11-25-2011
markspace schrieb:
> On 11/25/2011 11:59 AM, Jan Burse wrote:
>> markspace schrieb:
>>> For special pruposes Java also has things like memory buffers for
>>> logging.

>>
>> Which classes? Part of JDK or some utility?

>
>
> It wouldn't kill you to look through the Java API yourself, you know.
> Specifically for the logger, since that's what you seem to be interested
> in:
>
> <http://docs.oracle.com/javase/7/docs/api/java/util/logging/MemoryHandler.html>
>
>
>


No the memory stream need not be cyclic. The Java/J2ME
code reference I gave has maximally 256*chunks of size
16384 each. And there is something with a cicular buffer
in it.

But I guess the .NET memory streams are not cyclic. I am
looking for something like the .NET memory streams, so
that I can get rid of temporary file names in my
application.

Bye
 
Reply With Quote
 
Jan Burse
Guest
Posts: n/a
 
      11-25-2011
Jan Burse schrieb:
>
> But I guess the .NET memory streams are not cyclic. I am
> looking for something like the .NET memory streams, so
> that I can get rid of temporary file names in my
> application.


http://msdn.microsoft.com/en-us/libr...orystream.aspx
 
Reply With Quote
 
markspace
Guest
Posts: n/a
 
      11-25-2011
On 11/25/2011 12:23 PM, Jan Burse wrote:
> Jan Burse schrieb:
>>
>> But I guess the .NET memory streams are not cyclic. I am
>> looking for something like the .NET memory streams, so
>> that I can get rid of temporary file names in my
>> application.

>
> http://msdn.microsoft.com/en-us/libr...orystream.aspx


<http://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayOutputStream.html>

<http://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayInputStream.html>


 
Reply With Quote
 
Jan Burse
Guest
Posts: n/a
 
      11-25-2011
markspace schrieb:
> On 11/25/2011 12:23 PM, Jan Burse wrote:
>> Jan Burse schrieb:
>>>
>>> But I guess the .NET memory streams are not cyclic. I am
>>> looking for something like the .NET memory streams, so
>>> that I can get rid of temporary file names in my
>>> application.

>>
>> http://msdn.microsoft.com/en-us/libr...orystream.aspx

>
> <http://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayOutputStream.html>
>
>
> <http://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayInputStream.html>
>
>
>


The memory stream should be sharable.
Thats why I wrote:

> Requirement will be multiple readers / writers


And also seekable.
Thats why I wrote.

> and positioning.


To my knowledge ByteArrayOutputStream and ByteArrayInputStream
do not satisfy these requirements.

Bye
 
Reply With Quote
 
Jan Burse
Guest
Posts: n/a
 
      11-25-2011
Jan Burse schrieb:
> The memory stream should be sharable.


Well to some extend ByteArrayOutputStream and
ByteArrayInputStream are shareble. They are
at least thread safe, I find:

public synchronized void write(int b) {

So the same output object can be used by multiple
threads. And the same input object can be used
by multiple threads.

But I would like to be able to do the same as with
a temporary file. Some threads open it for read,
and some threads open it for write.

Bye
 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      11-25-2011
On 11/25/2011 12:39 PM, Jan Burse wrote:
> Would be interested in a good memory stream
> implementation. Requirement will be multiple
> readers / writers and positioning.
>
> Just found this code:
>
> http://www.mikepaul.ca/index.php?opt...e-dev&Itemid=4
>
> .Net style MemoryStream for Java/J2ME!
> Thursday, 27 May 2010 22:52 | Written by Michael Paul
>
> Although it has read / write and positioning,
> I don't think it is thread safe. Any other
> implementations around.
>
> Maybe some operations that provide InputStream /
> OutputStream factory methods.


Use java.nio.ByteBuffer and handle concurrency in your code.

Arne


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
out of memory while expanding memory stream v2brothers Computer Support 1 08-29-2007 11:11 AM
what is the different between byte stream and character stream? dolphin Java 6 03-18-2007 01:58 PM
get stream mode flags from an opened stream Alexander Korsunsky C++ 1 02-17-2007 10:38 AM
How to GET multi-word input from a *file* stream as opposed to a *console* stream? sherifffruitfly@gmail.com C++ 9 04-27-2006 04:14 PM
Doing readline in a thread from a popen4('rsync ...') stream blocks when the stream ends. Rasmusson, Lars Python 1 04-30-2004 08:10 AM



Advertisments