New Problem
Hi again.
I've updated my prog and now ive got an entirely new error.
Im having a problem reading from a file.
Any help is appreciated.
I know i must have gone very wrong somewhere.
Cheers.
/**Logon Screens
*@author Nathan Lasseter
*@version 1.2.1
*
*Must be same number of users as passwords
*but can have different number of domains
*
*Any user can access any domain
*/
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.EOFException;
import javax.swing.JOptionPane; //Import the JOptionPane package
public class hackingfile{ //begin main class
public static void main(String args[]){ //begin executing from here
String username,coreusers[][]; //input user and users
String passcode; //input password
String domain, coredoms[]; //input domain and domains
int passcodeint; //integer passcode and passcodes
int i=0,usernumber=0; //i for loops and usernumber for relating
user to pass
Boolean user=false,pass=false,dom=false; //checks for
authentication
DataInputStream in = new DataInputStream(new
BufferedInputStream(new FileInputStream(users.txt)));
try{
while(true){
coreusers[i][0] = in.readUTF;
coreusers[i][1] = in.readInt;
i++;
}
}catch(EOFException e){}
i=0;
DataInputStream in = new DataInputStream(new BufferedInputStream(new
FileInputStream(domains.txt)));
try{
while(true){
coredoms[i] = in.readUTF;
i++;
}
}catch(EOFException e){}
i=0;
username = JOptionPane.showInputDialog("Enter UserName"); //get
username from user
passcode = JOptionPane.showInputDialog("Enter PassCode"); //get
passcode from user
domain = JOptionPane.showInputDialog("Enter Domain"); //get
domain from user
passcodeint = Integer.parseInt(passcode); //parse string
passcode into integer
for(i=0;i<coreuser.length;i++){ //check username
if(username.equalsIgnoreCase(coreuser[i][0])){ //against list
user = true; //if correct username is authentic
usernumber=i; //get usernumber
}
}
if(passcodeint == coreusers[usernumber][1]) pass = true; //if
correct then passcode is authentic
for(i=0;i<coredoms.length;i++){ //check domain against list
if(domain.equalsIgnoreCase(coredoms[i])) dom = true; //if
correct then domain is authentic
}
if(user & pass & dom){ //if username, passcode and domain are
authentic grant access
JOptionPane.showMessageDialog(null,"Access Granted","Login
Successful",JOptionPane.PLAIN_MESSAGE); //show access is granted
}else{ //else deny access
JOptionPane.showMessageDialog(null,"Access Denied","Login
Unsuccessful",JOptionPane.PLAIN_MESSAGE); //show access is denied
}
} //end execution here
} //end main class
users.txt:
"admin" 101
"root" 798
"user1" 236
"nathan" 457
domains.txt:
"Google"
"LRGS"
"MyNet"