Advertisement
Ruslan_Isaev

hashmap

Jan 21st, 2021
913
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. @SuppressWarnings("unchecked")
  2.     public static HashMap<String, Integer> readWarningsFile()
  3.             throws ClassNotFoundException, IOException
  4.     {
  5.         try (ObjectInputStream is = new ObjectInputStream(new FileInputStream(PATH))) {
  6.             return (HashMap<String, Integer>) is.readObject();
  7.         }
  8.     }
  9.    
  10.     public static void saveWarningsFile(HashMap<String, Integer> users)
  11.             throws IOException
  12.     {
  13.         File f = new File(WHITELIST_PATH);
  14.         f.mkdirs();
  15.         if(!f.exists())
  16.             f.createNewFile();
  17.  
  18.         try (ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(PATH))) {
  19.             os.writeObject(users);
  20.         }
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement