TheQuack45

Untitled

Sep 30th, 2014
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. public static boolean checkSender(String sender) {
  2.         String fileName = "L:/HypeBotWorkspace/HypeBot/src/config/allowedUsers.txt";
  3.         File file = new File(fileName);
  4.         String current;
  5.         int lineCount = 0;
  6.         String[] allowedArray = null;
  7.         boolean isAllowed = false;
  8.        
  9.         Scanner fileIn;
  10.         Scanner fileIn2;
  11.         try {
  12.             fileIn = new Scanner(file);
  13.             fileIn2 = new Scanner(file);
  14.            
  15.             while (fileIn.hasNextLine()) {
  16.                 lineCount++;
  17.                 fileIn.next();
  18.             }
  19.            
  20.             allowedArray = new String[lineCount];
  21.            
  22.             for (int i = 0; i < allowedArray.length; i++) {
  23.                 current = fileIn2.next();
  24.                 allowedArray[i] = current;
  25.             }
  26.         } catch (FileNotFoundException e) {
  27.             e.printStackTrace();
  28.         }
  29.        
  30.         for (int i = 0; i < allowedArray.length; i++) {
  31.             if (sender.equals(allowedArray[i])) {
  32.                 isAllowed = true;
  33.             }
  34.         }
  35.        
  36.         return isAllowed;
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment