Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: WERTY WERTY
Added: Oct 5, 2019 3:12 AM
Views: 9
Tags: no tags
  1. package tanks;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.io.PrintWriter;
  6. import java.util.ArrayList;
  7. import java.util.Scanner;
  8.  
  9. public class Ban {
  10.    public static ArrayList<String> Nick = new ArrayList();
  11.  
  12.    public static void addNick(String nick) {
  13.       Nick.add(nick);
  14.    }
  15.  
  16.    public static void removeNick(String nick) {
  17.       Nick.remove(nick);
  18.    }
  19.  
  20.    public static boolean checkNick(String nick) {
  21.       return Nick.contains(nick);
  22.    }
  23.  
  24.    public static void loadNICK() throws IOException {
  25.       File fl = new File("Bans/NICK.txt");
  26.       if (!fl.exists()) {
  27.          fl.createNewFile();
  28.       }
  29.  
  30.       Scanner scn = new Scanner(fl);
  31.  
  32.       while(scn.hasNextLine()) {
  33.          addNick(scn.nextLine());
  34.       }
  35.  
  36.    }
  37.  
  38.    public static void saveNICK() {
  39.       try {
  40.          File file = new File("Bans/NICK.txt");
  41.          PrintWriter out = new PrintWriter(file);
  42.          if (!file.exists()) {
  43.             file.createNewFile();
  44.          }
  45.  
  46.          for(int i = 0; i < Nick.size(); ++i) {
  47.             out.append(Nick.get(i) + "\n");
  48.          }
  49.  
  50.          out.close();
  51.       } catch (IOException var3) {
  52.       }
  53.  
  54.    }
  55. }
  56.