Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Problems with readObject();

  1. #1
    Member
    Join Date
    Apr 2013
    Posts
    43
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default Problems with readObject();

    Hello!

    I have a three java classes: Client, Server and Cap. Cap implements Serializable and doesn't contain any object that doesn't do the same. The client is sending an object of Cap to the server through sockets and the server is recieving it like this:

    in = new ObjectInputStream(socket.getInputStream());
    out = new ObjectOutputStream(socket.getOutputStream());
     
    Cap cap = (Cap) in.readObject();

    Under the last code line I want to call different methods that Cap have, but it doesn't work. I'm using NetBeans and the method options is equals, getClass, hashcode....

    It seems like the cast to Cap doesn't work. What am I doing wrong?

    Hank


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Problems with readObject();

    it doesn't work.
    What does "doesn't work" mean?
    Please copy the full text of any error message and paste it here. It has important info about the error.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Feb 2014
    Location
    India
    Posts
    47
    My Mood
    Bored
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Default Re: Problems with readObject();

    The casting part seems to be fine. Maybe there is a problem somewhere else. It would be good if you could share the error message as indicated by @Norm.

  4. #4
    Member
    Join Date
    Apr 2013
    Posts
    43
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default Re: Problems with readObject();

    Well, it suddenly worked. I have no idea what was wrong...

    Thank you for the interest!

Similar Threads

  1. EOF Exception using InputStream/ReadObject
    By ryumishima44 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: July 20th, 2012, 06:06 AM
  2. Problems with my HW
    By hws in forum Object Oriented Programming
    Replies: 14
    Last Post: December 30th, 2011, 12:18 PM
  3. Programming Problems Need Help
    By ChuckLep in forum What's Wrong With My Code?
    Replies: 5
    Last Post: December 11th, 2011, 07:58 PM
  4. JUnit problems
    By degude in forum Java SE APIs
    Replies: 8
    Last Post: September 19th, 2011, 05:54 AM
  5. 2 problems...
    By Day2Day in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 22nd, 2010, 02:51 PM