public void getSavedLocations() { // System.out.println("inside getSavedLocations"); //CONSOLE * * * * * * * * * * * * * loc.clear(); // clear locations. helps refresh the list when reprinting all the locations BufferedWriter f = null; // just in case file has not been created yet BufferedReader br = null; try { // attempt to open the locations file if it doesn't exist, create it f = new BufferedWriter( new FileWriter("savedLocations.txt", true)); // evaluated true if file does not exist br = new BufferedReader(new FileReader("savedLocations.txt")); String line; // each line is one index of the list loc.add("Saved Locations"); // loop and read a line from the file as long as we don't get null while ((line = br.readLine()) != null) // add the read word to the wordList loc.add(line); } catch (IOException e) { e.printStackTrace(); } finally { try { // attempt the close the file br.close(); // close bufferedwriter } catch (IOException ex) { ex.printStackTrace(); } } }
/** If a key is pressed perform the respective actions */ public void keyPressed() { // Add 'stems' to the balls if (keyCode == SHIFT) { stems = !stems; for (int i = 0; i < balls.size(); i++) { Ball b = (Ball) balls.get(i); b.STEM = stems; } } // toggle repaint background else if (key == 'b') REPAINT = !REPAINT; // Empty the ArrayList of Balls else if (key == 'x') balls.clear(); // Add a ball else if (key == 'f') addBall(); }
public void closeNetworking() { for (FixedTimer timer : timers) timer.stop(); timers.clear(); if (Global.connectingSocket != null) { try { Global.connectingSocket.close(); } catch (IOException ex) { } } closeClient(mainServer); closeClient(bulletStream); closeClient(powerStream); closeClient(turretStream); closeClient(powerRemover); closeClient(chatLog); closeClient(fadeLog); closeClient(serverTime); if (playerByteStreams != null) { for (int i = 0; i < playerByteStreams.length; ++i) { closeClient(playerByteStreams[i]); } } }