Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean checkSender(String sender) {
- String fileName = "L:/HypeBotWorkspace/HypeBot/src/config/allowedUsers.txt";
- File file = new File(fileName);
- String current;
- int lineCount = 0;
- String[] allowedArray = null;
- boolean isAllowed = false;
- Scanner fileIn;
- Scanner fileIn2;
- try {
- fileIn = new Scanner(file);
- fileIn2 = new Scanner(file);
- while (fileIn.hasNextLine()) {
- lineCount++;
- fileIn.next();
- }
- allowedArray = new String[lineCount];
- for (int i = 0; i < allowedArray.length; i++) {
- current = fileIn2.next();
- allowedArray[i] = current;
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- for (int i = 0; i < allowedArray.length; i++) {
- if (sender.equals(allowedArray[i])) {
- isAllowed = true;
- }
- }
- return isAllowed;
- }
Advertisement
Add Comment
Please, Sign In to add comment