0

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..?

Edited by Abibina: n/a

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by javaAddict
0

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

Edited by javaAddict: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.