Solved

check out object stream

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
nextBoolean(double p) for Random class 3 40
fibonacci ten numbers 4 40
java jdbc batch example 8 35
runtime exception 2 30
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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 tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

831 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