?
Solved

Streams ad RMI parameters

Posted on 1998-11-12
5
Medium Priority
?
169 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 800 total points
ID: 1227343
I am glad it worked.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month8 days, 22 hours left to enroll

764 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