anyone know how to split the text in txt file i have this...

try {
            String newaccount = NewAccount.getText();
            String newaccusername = NewAccUsername.getText();
            String newaccpassword = NewAccPassword.getText();
            FileWriter filewriter = new FileWriter(newaccount + ".txt");
            BufferedWriter out = new BufferedWriter(filewriter);
            out.write(newaccpassword);
            out.write(newaccusername);
            //out.write(newAccount);
            out.close();
            LabelInfo.setText("Account Registered !");
        } catch (Exception ex) {
        }

Recommended Answers

All 3 Replies

What is the output you are getting now, and what is your desired output?

reader:

FileReader freader = null;
        try {
            String accountName = LoginUsername.getText();
            String password = LoginPassword.getText();
            freader = new FileReader(accountName + ".txt");
            BufferedReader reader = new BufferedReader(freader);
            String filePass = reader.readLine();
            if (password.equals(filePass)) {
                LabelInfo.setText("Password and Username accepted");
                new Info().setVisible(true);

            } else {
                LabelInfo.setText("Wrong password!");
            }
        } catch (IOException ex) {
            LabelInfo.setText("Wrong username!");
        } finally {
            try {
                freader.close();
            } catch (IOException ex) {
                Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

What is the output you are getting now, and what is your desired output?

what ?? :S o_0

also, don't do this:

catch (Exception ex) {
        }

how are you going to know whether or not there's an Exception thrown?

what ?? :S o_0

he meant: what is it exactly you expect as result, and what is the result you are currently getting?

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.