Solved

Streams ad RMI parameters

Posted on 1998-11-12
5
164 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
ID: 1227339
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
ID: 1227340
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
ID: 1227341
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
ID: 1227342
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
ID: 1227343
I am glad it worked.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MySQL  on Tomcat 8 70
Unhandled exception type Exception 18 43
Need Help! Getting a syntax error and don't understand why 3 31
running on tomcat not jboss eap 7.0 3 18
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.

828 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