Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

override the Serializable method

Posted on 1999-07-15
5
Medium Priority
?
154 Views
Last Modified: 2010-04-16
How do i override the readObject for my message class that i recieve from the network using a datagram socket ?
Do you have an example .
0
Comment
Question by:sector
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 16

Expert Comment

by:heyhey_
ID: 1246127
do tou need something like this ?
(btw. take a look at "Java Tutorial" - online tutorial at www.javasoft.com)


long l;

private void writeObject(ObjectOutputStream s)
  throws IOException
{
  s.defaultWriteObject();
  s.writeLong(l);
}


private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException
{
   s.defaultReadObject();
   l = s.readLong();
}

0
 

Author Comment

by:sector
ID: 1246128
Can you tell me how do i parse from an byte[] to int ?
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 1246129
the easiest solution is
byte[] buf;
int i = buf[pos] << 24 | buf[pos+1] << 16 | buf[pos+2] < 8 | buf[pos]


'- Class java.io.DataInputStream -
 public final int readInt() throws IOException
Reads a signed 32-bit integer from this data input stream. This method reads four bytes from the underlying input stream. If the bytes read, in order, are b1, b2, b3, and b4, where 0 <= b1, b2, b3, b4 <= 255, then the result is equal to:

(b1 << 24) | (b2 << 16) + (b3 << 8) +b4'
0
 
LVL 16

Accepted Solution

by:
heyhey_ earned 400 total points
ID: 1246130
time for Answer.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6828160
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  Or if you are an EE Pro user, click the link below to select open items for your Member ID using Power Search:
http://www.experts-exchange.com/jsp/qPowerSearch.jsp.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.

http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
http://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thank you,
Moondancer
Moderator @ Experts Exchange
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

722 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