Solved

Streams ad RMI parameters

Posted on 1998-11-12
5
160 Views
Last Modified: 2010-03-30
Hi,

I would like to pass a stream as a parameter of a remote method, but I have no success doing so.

If anyone know how it may be achived I will be most thanksfull.

Thanks,
Guy Loewy.
0
Comment
Question by:optimal
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:msmolyak
Comment Utility
Not a stream object I hope. Imagine you create a file input stream object which has the name of a local file and logic on how to read it. If you manage to pass that object to the remote machine, what good will it do there?

The alternatives are:

1. Reading the entire stream in serializable data structure (String for example) and pass it as a parameter.
2. If the stream contains too much data, you can use Sockets to communicate between the client and the server side.

If you describe you situation I might be able to think of something better.

Michael
0
 

Author Comment

by:optimal
Comment Utility
Hi msmolyak,

I already tried to read the stream into a string, but it seems that either using FileInputStream (which means using byte[]) or FileReader (which means using char[]) and storing the data in a String object cause my application to loose data (I transfer binary files). Some of the bytes are being altered (according to the data from the String contents.I found it strange, but maybe that's because String converts bytes into chars or visa versa. Anyway, the String on the remote Server is altered and the binary file is not the same.
I might use sockets, but I'm sure it should be posibble to transfer whole binary files in one chunk.
0
 
LVL 5

Expert Comment

by:msmolyak
Comment Utility
If the file is binary I would not use Readers and Strings. Stick with byte arrays. Did you try to encapsulate a binary array into some serializable object, Vector, for example and then pass that object as a parameter. First use ByteArrayOutputStream to write the data you read from your stream, then convert it to byte array, this way you would not have to concatenate pieces manually.
0
 

Author Comment

by:optimal
Comment Utility
Thanks msmolyak,

I used a Vector object to move the byte arrays and it works great,

Guy.

Pealse send as an answer.
0
 
LVL 5

Accepted Solution

by:
msmolyak earned 200 total points
Comment Utility
I am glad it worked.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This video teaches viewers about errors in exception handling.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now