Skip to content

Commit

Permalink
fixed issue #6 using random number
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandalorian committed Nov 11, 2019
1 parent 1d7bbdc commit 8d9729e
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.net.URL;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Random;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.SortedSet;
Expand Down Expand Up @@ -624,7 +625,7 @@ private void handleFileOpenAction(ActionEvent event) throws IOException {
// handler for menu item -> Open ZIP file event
private void handleFileOpenZipAction(ActionEvent event) throws IOException {
Boolean fileGood = true;
File targetFile = new File("unzippedJMXDumpfile.txt");
File targetFile = new File("unzippedJMXDumpfile"+getRandomNumber()+".txt");
FileChooser fileChooser = new FileChooser();
FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("ZIP files (*.zip)", "*.zip");
fileChooser.getExtensionFilters().add(extFilter);
Expand Down Expand Up @@ -765,7 +766,7 @@ public void run() {

try {
if (file.getName().toLowerCase().endsWith(".zip")) {
File unzippedFile = new File("unzippedJMXDumpfile.txt");
File unzippedFile = new File("unzippedJMXDumpfile"+getRandomNumber()+".txt");
if (extractZipFile(new ZipFile(file), unzippedFile)){
localParse(unzippedFile.getCanonicalPath());
}
Expand Down Expand Up @@ -1863,4 +1864,19 @@ public static double round(double value, int places) {
return bd.doubleValue();
}


/**
* random number generator. Hard coded bound between 1 and 100.
*
* @return int which is randomly generated between 1 and 100.
*/
private int getRandomNumber() {

int min = 1;
int max = 100;

Random r = new Random();
return r.ints(min, (max + 1)).findFirst().getAsInt();

}
}

0 comments on commit 8d9729e

Please sign in to comment.