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

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;

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

        try
        {
            boolean done = false;
            int data;

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.