Solved

check out object stream

Posted on 2012-03-23
5
506 Views
Last Modified: 2012-06-08
I want to use both socket type , string and object stream.

sometime the socket will receive the data consists of String and sometime object.

It has to be just one port used.

so ,

I have to know the data in socket is String or object stream.
Is there way to check it out?

How can I solve this out?
0
Comment
Question by:gamjaradio
  • 2
  • 2
5 Comments
 
LVL 26

Assisted Solution

by:ksivananth
ksivananth earned 250 total points
ID: 37756018
can't you make the strings be sent as object?
0
 

Author Comment

by:gamjaradio
ID: 37756020
of course it is possbile.
but , there are so many code that I have to change.
0
 
LVL 26

Assisted Solution

by:ksivananth
ksivananth earned 250 total points
ID: 37756027
>>but , there are so many code that I have to change.

I think, the only place where you'll have to make change is while writing and extracting data
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 250 total points
ID: 37756059
Sure, you transmit ObjectStream and when you get back Object using instanceof operator
check all possible types to which Object can belong  including String and other possible objects which you'll transmit. You can create such method and replcae in all places
0
 
LVL 47

Accepted Solution

by:
for_yan earned 250 total points
ID: 37756073
Do you really have many places where you are sending and receiveing them bothe wyas where you need to change?
Post the code how you do it in each case, maybe we could think of some way to minimize changes
Do you have big numbers of both cases?
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
arguments to jar 5 40
JavaFX TableView not displaying correctly 3 109
maven disable workspace resolution 1 42
printf performancy 11 86
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to implement Singleton Design Pattern in Java.

726 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