I m creating the page which contains username n password.. I dont know how to store the username n password in a file n to display an error message if the username or password is wrong .. how to do this.. ll anyone explain me using a simple program..?

Reading and writing to file using Buffered.....

BufferedWriter writer = null;
        try {
            writer = new BufferedWriter(new FileWriter(file));
           
                writer.write("Line is written to file");
                writer.newLine();
        } catch (IOException ioe) {
            System.out.println("Error: "+ioe.getMessage());
        } finally {
            if (writer!=null) writer.close();
        }
BufferedReader reader = null;
try {
            reader = new BufferedReader(file);
            String line = reader.readLine();
            while (line!=null) {
                System.out.println("Line read: "+line); 
                
                line = reader.readLine();
            }
        } catch (IOException ioe) {
            System.out.println("Error: "+ioe.getMessage());
        } finally {
            if (reader!=null) reader.close();
        }

For more info ask more specific questions

Also check the API of the above classes at:

http://java.sun.com/javase/6/docs/api/java/io/package-summary.html

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.