The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 305 Weeks Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Hello, I could use some help. Both files compile fine in Netbeans but when I run it I get the following error messages.
java.io.FileNotFoundException: Credentail.txt (The system cannot find the file specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at java.io.FileReader.<init>(FileReader.java:58)
at authenticationsystem.AuthenticationSystem.loginScreenpro(AuthenticationSystem.java:71)
at authenticationsystem.AuthenticationSystem.main(AuthenticationSystem.java:28)
Â
I have also provided the credentials text file along with my pseudocode file. Any changes made to the java file will also need to be made to the pseudocode along with an explanation. Thanks for any and all help with this./*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package authenticationsystem;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Scanner;
/**
 *
 * @author jack
 */
public class AuthenticationSystem {
   /**
    * @param args the command line arguments
    * @throws java.io.IOException
    */
   public static void main(String[] args) throws IOException {
       // TODO code application logic here
       loginScreenpro();
   }
   public static void loginScreenpro() {
       String gPassword = "";
       int flag123 = 0, attempts123 = 3;
       BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));
       System.out.println("Login");
       try {
           do {
               attempts123--;
               System.out.println("Enter Username");
               String userName = br1.readLine();
               System.out.println("Enter Password");
               String password = br1.readLine();
               MessageDigest md123 = MessageDigest.getInstance("md5");
               md123.update(password.getBytes());
               byte[] bytes12 = md123.digest();
               StringBuilder sb1 = new StringBuilder();
               for (byte b : bytes12) {
                   sb1.append(String.format("%02x", b & 0xff));
               }
               gPassword = sb1.toString();
               String currentLine;
               BufferedReader bin123 = new BufferedReader(new FileReader("Credentail.txt"));
               while ((currentLine = bin123.readLine()) != null) {
                   String[] array123 = currentLine.split(" ");
                   if (array123[0].equals(userName)) {
                       if (array123[1].equals(gPassword)) {
                           flag123 = 1;
                           break;
                       }
                   }
               }
               if (attempts123 == 0) {
                   System.out.println("login more times");
                   System.out.println("Exit...");
                   System.exit(0);
               }
               if (flag123 == 1) {
                   adminScreenpro();
                   break;
               } else {
                   System.out.println("Invalid Username or Password.");
                   System.out.println(" try again.");
                   System.out.println(attempts123 + " more attemptes left.n");
               }
           } while (attempts123 > 0);
       } catch (NoSuchAlgorithmException e1) {
           e1.printStackTrace();
       } catch (IOException e1) {
           e1.printStackTrace();
       }
   }
   public static void adminScreenpro() {
       String logOut123;
       Scanner sc1 = new Scanner(System.in);
       System.out.println("Welcome Admin");
       System.out.println("user Press 99 for log outn");
       do {
           logOut123 = sc1.nextLine();
       } while (!logOut123.equals("99"));
       if (logOut123.equals("99")) {
           loginScreenpro();
       }
   }
}
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly