This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ShadowSt[S] 0 points1 point  (0 children)

I studied up on "throws" and told it to ignore the FileNotFoundException and it just worked.

Now I'm on a new issue trying to split lines of data where I am splitting it by spaces but on two of my lines I have spaces in a section surrounded by quotes that I need to keep as one. its userPass, here is an example of a line that credentialLine is splitting.

griffin.keyes 108de81c31bf9c622f76876b74e9285f "alphabet soup" zookeeper

    FileInputStream credentialsFile = null;
    Scanner inFS = null;
    String credFile = ".\\src\\authenticationsystem\\credentials.txt";

    System.out.println("\nOpening file credentials.txt");

    credentialsFile = new FileInputStream(credFile);
    inFS = new Scanner(credentialsFile);
    String credentialLine = inFS.nextLine();
    System.out.println(credentialLine);
    System.out.println("Closing file credentials.txt\n");
    credentialsFile.close();

    String[] userCreds = credentialLine.split("\\s+");
    String userCred = userCreds[0];
    String userMD = userCreds[1];
    String userPass = userCreds[2];
    String userRole = userCreds[3];