Helo every one.
i m workin with jlist and i got several items in jlist i want to store this items into txt file and read it later. is it possible to do it? any help will be apprict. hop i explained wel ... thx

Attachments Capture.JPG 19.9 KB

Yes; use Serializable. (Assuming all you want to do is save your JList and restore it when you restart, you can use Serializable to save your Objects, then you can easily restore them into the JList).

Thank you for ur reply. can u pls explain bit more bout it. that would be helpful thanks

U can ofcourse... i have sample program here that will write file in text its up to you how you gonna revise it..

package cs344;
import java.io.*;

public class WriteFile
    public static void main (String [] args)throws IOException
        String filename;
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

        System.out.println("Enter filename");
        filename = input.readLine();

        System.out.println("Enter data to write to" + filename);
        System.out.println("Type @ to end");

        FileOutputStream fos = null;

        fos = new FileOutputStream(filename);
        }catch(FileNotFoundException e)
        {System.out.println("File cannot be openned for writing... ");}

            boolean done = false;
            int data;

                data = input.read();
                if((char)data == '@')
                    done = true;
        }catch(IOException er){System.out.println("Error reading from file");}

Edited 3 Years Ago by Nick Evan: Fixed formatting

Just google Serializable. Why would I bother to rewrite something that already has plenty of resources available? Especially when the available resources are written by people with more knowledge of the concept than I have?

If you want specific answers, ask specific questions. If you want me to write an article about Serializable, go away.

This article has been dead for over six months. Start a new discussion instead.