Solved

Vector serialization

Posted on 2001-07-27
4
1,655 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

738 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