Advertisement
Gamebuster

Potato.class sample

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