Solved

Vector serialization

Posted on 2001-07-27
4
1,662 Views
Last Modified: 2010-05-18
Is it possible to serialize a vector, and if so how?

thanks in advance...
ck
0
Comment
Question by:captainklink
[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
4 Comments
 
LVL 1

Accepted Solution

by:
Recall earned 50 total points
ID: 6326267
Yes it is.  Vector implements the Serializable interface, so you can simply create a FileOutputStream and write your object to it ...

See here for more info

http://developer.java.sun.com/developer/technicalArticles/Programming/serialization/

Recall
0
 
LVL 1

Expert Comment

by:googlyralph
ID: 6326272
yes, its just an object, and as such you can call a write method on it.

//Vector writing class

Vector myVector = new Vector();
try{
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("theVEctorFile"));
out.writeObject(myVector);
out.close();
}catch(Exception e){
System.out......
}

Googly Ralph.
0
 
LVL 92

Expert Comment

by:objects
ID: 6326338
Just make sure all the elements in the Vector are serializable.
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 8975297
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:


-- points to Recall


Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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 covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

628 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