Advertisement
Gamebuster

Potato.class sample

Aug 23rd, 2016
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. if (message.toLowerCase().startsWith("!whitelist @")) {
  2.     String msg = message.substring(message.lastIndexOf("@", message.length())) + "\r\n";
  3.     try{
  4.         BufferedWriter bw = new BufferedWriter(new FileWriter(new File(Paths.get("./whitelist.txt").toUri())));
  5.         try {
  6.             System.out.println("Writing to file:");
  7.             bw.write(msg);
  8.             bw.write(msg + "this is a test bla bla bla \n test test test");
  9.             // group.sendMessage(message.substring(message.lastIndexOf("@"), message.length()) + " has been added to the whitelist"); //should only show message if they are actually added to the whitelist
  10.             } catch (IOException e) { // This means that for some reason it failed to write the message
  11.                 //let it crash, or handle the exception
  12.             } finally { //always runs, whether or not an exception is thrown
  13.                 bw.flush(); //MUST FLUSH AND CLOSE THE STREAM EVEN IF IT FAILS TO WRITE TO THE FILE TO PREVENT MEMORY LEAKS
  14.                 bw.close();
  15.             }
  16.         }
  17.         catch (IOException e){
  18.             System.out.println("Unable to access file");
  19.             //let it crash, or handle the exception
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement