1

I am making a networking site for a fun programming project. I want to add a log in screen, using a Jframe and once they log in, it will go to the second JFrame carrying over all of the information. So lets call the first one "logIn" and the second one "socialNetwork".

What i am trying to do essentially is have a read/write file in the program and have each line be a user name and a password, also an option to create a new profile which will then add on to the file. If a user hits the log in button on "logIn" I will read the file and if they user name and password match, It will then send or bring up the main Profile viewer or the "socialNetwork" Is there a line of code in order to do that? Is there a tutorial you can link me? I don't think I am searching for the right thing when I look for it.

tenorsax
  • 21,123
  • 9
  • 60
  • 107
Renuz
  • 1,587
  • 7
  • 21
  • 34
  • 2
    You may find [How to proceed from login screen to the next screen? JPanel, JFrame?](http://stackoverflow.com/q/9910409/1048330) useful. – tenorsax May 08 '12 at 23:21
  • 2
    See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/418556) – Andrew Thompson May 08 '12 at 23:43

1 Answers1

0

It seems you would need to use the PrintWriter. How do I create a file and write to it in Java?

reading the file you would use something like this

String delims = "[ ]+";
Scanner fileScan = new Scanner(new File("theFileName"));

while(fileScan.hasNext()){
    String str = fileScan.nextLine();
    String[] tokens = str.split(delims);
  ...

//now your tokens[0] has username
// and tokens[1] has password
...//do something with it
}
Community
  • 1
  • 1
wabatt
  • 13
  • 4