diff --git a/代码/workspace_robo4/plugins/testing/robocode.testing.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java b/代码/workspace_robo4/plugins/testing/robocode.testing.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java index e993cf8..c29ae3f 100644 --- a/代码/workspace_robo4/plugins/testing/robocode.testing.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java +++ b/代码/workspace_robo4/plugins/testing/robocode.testing.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java @@ -46,8 +46,9 @@ public class AutoExtract implements ActionListener { try { JarFile extractJar = new JarFile("extract.jar"); - + is = extractJar.getInputStream(extractJar.getJarEntry("license/cpl-v10.html")); + extractFJar.close(); } catch (IOException e) { return true; } @@ -250,7 +251,7 @@ public class AutoExtract implements ActionListener { } File installDir = null; - File suggestedDir; + File suggestedDir;s AutoExtract extractor = new AutoExtract(); diff --git a/代码/workspace_robo4/robocode.host/src/test/java/net/sf/robocode/host/jarjar/JarJarTest.java b/代码/workspace_robo4/robocode.host/src/test/java/net/sf/robocode/host/jarjar/JarJarTest.java index 6cf90e1..9a4bf13 100644 --- a/代码/workspace_robo4/robocode.host/src/test/java/net/sf/robocode/host/jarjar/JarJarTest.java +++ b/代码/workspace_robo4/robocode.host/src/test/java/net/sf/robocode/host/jarjar/JarJarTest.java @@ -68,5 +68,6 @@ public class JarJarTest { ClassLoader ucl = new URLClassLoader(new URL[] { u}); ucl.loadClass(clas); + ucl.close(); } } diff --git a/代码/workspace_robo4/robocode.host/src/test/resources/Outer.jar b/代码/workspace_robo4/robocode.host/src/test/resources/Outer.jar deleted file mode 100644 index 4b539ff..0000000 Binary files a/代码/workspace_robo4/robocode.host/src/test/resources/Outer.jar and /dev/null differ diff --git a/代码/workspace_robo4/robocode.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java b/代码/workspace_robo4/robocode.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java index e4c6d0a..dcb9816 100644 --- a/代码/workspace_robo4/robocode.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java +++ b/代码/workspace_robo4/robocode.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java @@ -68,6 +68,7 @@ public class AutoExtract implements ActionListener { JarFile extractJar = new JarFile("extract.jar"); is = extractJar.getInputStream(extractJar.getJarEntry("license/cpl-v10.html")); + extractJar.close(); } catch (IOException e) { return true; } diff --git a/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/BattlesRunner.java b/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/BattlesRunner.java index 433cff6..13cbd64 100644 --- a/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/BattlesRunner.java +++ b/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/BattlesRunner.java @@ -161,6 +161,7 @@ public class BattlesRunner { String record; while ((record = br.readLine()) != null) { robots.add(record); + fr.close(); } } catch (IOException e) { System.out.println("Battles input file not found ... Aborting"); diff --git a/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/PrepareBattles.java b/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/PrepareBattles.java index b594e67..a2a30ca 100644 --- a/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/PrepareBattles.java +++ b/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/PrepareBattles.java @@ -76,7 +76,9 @@ public class PrepareBattles { BufferedReader br = null; try { - FileReader fr = new FileReader(participantsfile); + + + fr = new FileReader(participantsfile); br = new BufferedReader(fr); String participant; @@ -101,6 +103,7 @@ public class PrepareBattles { } } } + fr.close(); } catch (IOException e) { System.out.println("Participants file not found ... Aborting"); System.out.println(e); @@ -117,6 +120,7 @@ public class PrepareBattles { try { outtxt = new PrintStream(new BufferedOutputStream(new FileOutputStream(battlesfile)), false); + outtxt.close(); } catch (IOException e) { System.out.println("Not able to open battles file " + battlesfile + " ... Aborting"); System.out.println(e); @@ -201,6 +205,7 @@ public class PrepareBattles { } } } + fr.close(); } catch (IOException e) { System.out.println("Participants file not found ... Aborting"); System.out.println(e); @@ -241,6 +246,7 @@ public class PrepareBattles { } } } + fr.close(); } catch (IOException e) { System.out.println("Priority battles file not found ... "); } finally { diff --git a/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/BotsDownload.java b/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/BotsDownload.java index b8c2d87..d29b50b 100644 --- a/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/BotsDownload.java +++ b/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/BotsDownload.java @@ -259,6 +259,7 @@ public class BotsDownload { names.add(name); } } + fr.close(); } catch (IOException e) { System.out.println("Participants file not found ... Aborting"); System.out.println(e); @@ -299,6 +300,7 @@ public class BotsDownload { String name = record.substring(0, record.indexOf(",")); size.checkCompetitorForSize(name, 1500); } + fr.close(); } catch (IOException e) { System.out.println("Battles input file not found ... Aborting"); System.out.println(e); @@ -400,6 +402,7 @@ public class BotsDownload { String version = parameters.getProperty("team.version", ""); return (botname.equals(botname.substring(0, botname.indexOf(" ")) + " " + version)); + jarf.close(); } catch (Exception e) { System.out.println(e); return false; @@ -487,6 +490,7 @@ public class BotsDownload { } } } + fr.close(); } catch (IOException e) { System.out.println("Participants file not found when removing old participants ... Aborting"); System.out.println(e); diff --git a/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/ResultsUpload.java b/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/ResultsUpload.java index aaa5246..caa9979 100644 --- a/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/ResultsUpload.java +++ b/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/ResultsUpload.java @@ -105,6 +105,7 @@ public class ResultsUpload { results.add(bot2); } } + fr.close(); } catch (IOException e) { System.out.println("Can't open result file for upload"); return; diff --git a/代码/workspace_robo4/robocode.sound/src/main/java/net/sf/robocode/sound/SoundManager.java b/代码/workspace_robo4/robocode.sound/src/main/java/net/sf/robocode/sound/SoundManager.java index 9886d13..140bd26 100644 --- a/代码/workspace_robo4/robocode.sound/src/main/java/net/sf/robocode/sound/SoundManager.java +++ b/代码/workspace_robo4/robocode.sound/src/main/java/net/sf/robocode/sound/SoundManager.java @@ -133,6 +133,7 @@ public class SoundManager implements ISoundManager { if (m.getClass().getSimpleName().equals(mixerClassName)) { return m; } + m.close(); } return null; } diff --git a/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesSoundOptionsTab.java b/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesSoundOptionsTab.java index 37a71e3..9dc4e61 100644 --- a/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesSoundOptionsTab.java +++ b/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesSoundOptionsTab.java @@ -228,6 +228,7 @@ public class PreferencesSoundOptionsTab extends WizardPanel { if (AudioSystem.getMixer(mi).getSourceLineInfo(clipLineInfo).length > 0) { mixers.add(mi); } + mi.close(); } mixerComboBox = new JComboBox(mixers); @@ -318,6 +319,7 @@ public class PreferencesSoundOptionsTab extends WizardPanel { getMixerComboBox().setSelectedItem(mi); break; } + mi.close(); } } @@ -353,6 +355,7 @@ public class PreferencesSoundOptionsTab extends WizardPanel { boolean volumeSupported; boolean panSupported; + mixer.close(); try { Line line = mixer.getLine(lineInfo);