Solved

check out object stream

Posted on 2012-03-23
5
498 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
parentbit challenge 3 52
mapShare challenge 13 68
wordappend challenge 8 85
Basic Java Case or If-Else statement... 3 5
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 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…

758 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

21 Experts available now in Live!

Get 1:1 Help Now