Advertisement
Guest User

Untitled

a guest
May 26th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.36 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.Scanner;
  3. import java.util.Vector;
  4.  
  5. public class MedicalOrganizer {
  6.    
  7.    
  8.     public static void main(String[] args) {
  9.        
  10.         Scanner get = new Scanner (System.in);
  11.         Vector strUser, strPassword;
  12.         String strLoginU, strLoginP;
  13.         boolean blnLogged = false;
  14.        
  15.         strUser  = new Vector();
  16.         strPassword = new Vector();
  17.        
  18.         System.out.println ("Login...");
  19.        
  20.         while (blnLogged == false) {
  21.            
  22.             System.out.print ("\nUsername: ");
  23.             strLoginU = get.next();
  24.             System.out.print ("Password: ");
  25.             strLoginP = get.next();
  26.            
  27.             int i = 0;
  28.            
  29.             try {
  30.                 DataInputStream uin = new DataInputStream(new FileInputStream("Usernames.ini"));
  31.                 DataInputStream pin = new DataInputStream(new FileInputStream("Passwords.ini"));
  32.                 while ((uin.available() != 0) && (pin.available() != 0)) {
  33.                
  34.                     strUser.addElement(uin.readLine());
  35.                     strPassword.addElement(pin.readLine());
  36.                    
  37.                     if ((strLoginU.compareTo(String.valueOf(strUser.elementAt(i))) == 0) && (strLoginP.compareTo(String.valueOf(strPassword.elementAt(i))) == 0)) {
  38.                         blnLogged = true;
  39.                     }
  40.                    
  41.                     i++;
  42.                 }
  43.             } catch (Exception e) {
  44.                 System.err.println (e);
  45.             }
  46.            
  47.             if (blnLogged == false) {
  48.                
  49.                 System.out.println ("\nIvalid username/password, please try again.");
  50.             }
  51.         }
  52.        
  53.         System.out.println ("\nAccess granted.");
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement