No, but I'll help you learn how to do it yourself.
First read the introduction to the API docs for ObjectOutputStream and ObjectInputStream. You don't need to worry about any of the advanced bits, just the most basic simple example. You will use your Socket's output and input streams instead of file streams, but otherwize it's all there
That's the problem. You have written an array and you retrieve its "toString" representation - that's not the same - it gives the class name and its hash. If you look at the sample in the doc for ObjectInoutStream you will see that you have to cast the object you just read, eg
But there's no need to mess about putting the strings into an array, just write/read them directly:
System.out.println("data from socket is "+ (String) in.readObject() + (String) in.readObject());
That approach works for all kinds of objects, which is why I introduced it first, but if you read the doc for object streams you would have found that there's a special pair of methods just for Strings that saves the cast...
System.out.println("data from socket is "+ in.readUTF() + in.readUTF());
Object streams are not working, my all codes are working fine with data streams but when i use Object stream, i am getting some messy data instead the actual data. can u figure out the problem please help..
You said you tries all my suggestions. In that case you must have written compiled and tested code that uses writeUTF and readUTF. Post that code.
You said "getting nothing except the garbage value ... ". It may be garbage to you, but it will probably tell me something. Post that "garbage" value.
OK, so you didn't actually try any of my suggestions fully. You have some random mixture of object output with your old non-object input. That's never going to work.
Did you notice that I always had my streams and write/read methods in matched pairs?
Can you see anywhere that I said you could write an object to an ObjectOutputStream then read it from some other stream type?
Let me say this one more time very slowly...
if you writeUTF to an ObjectOutputStream then you have to readUTF from an ObjectInputStream
It's hopeless trying to debug your code when you only supply tiny fragments of it. Plus you contradict yourself "still i getting nothing except the garbage value ... " or "but fine with above method".
And you still haven't posted the "garbage values" that I asked for twice.
This is really very very simple.
Open an ObjectOutputStream on the socket's output stream and write the userName and password to it by calling writeUTF twice. flush() the ObjectOutputStream for good luck.
At the receiving end open an ObjectInputStream on the socket's input stream and read the userName and password by calling readUTF twice.
If you can't make that work then post ALL the relevant code and an exact copy of all relevant output
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...
Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...