OSDN Git Service

バージョン情報ダイアログをtry-with-resourcesを使って書き換え
authoryukihane <yukihane.feather@gmail.com>
Sat, 20 Aug 2011 19:43:57 +0000 (04:43 +0900)
committeryukihane <yukihane.feather@gmail.com>
Sat, 20 Aug 2011 19:43:57 +0000 (04:43 +0900)
frontend/src/saccubus/MainFrame_AboutBox.java

index 9d8ab8c..fd69a25 100644 (file)
@@ -8,7 +8,6 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -83,7 +82,7 @@ public class MainFrame_AboutBox extends JDialog implements ActionListener {
         *
         * @throws java.lang.Exception
         */
-       private void jbInit() throws Exception {
+       private void jbInit() {
         final JPanel basePanel = new JPanel();
 
         final JLabel imageLabel = new JLabel();
@@ -124,23 +123,19 @@ public class MainFrame_AboutBox extends JDialog implements ActionListener {
         setResizable(true);
        }
 
-    private JScrollPane createLicensePane() throws IOException {
+    private JScrollPane createLicensePane() {
         final JTextArea licenseField = new JTextArea();
-        InputStream res = null;
-        try {
-            res = saccubus.MainFrame_AboutBox.class.getResourceAsStream("LICENSE.txt");
-            final BufferedReader reader = new BufferedReader(new InputStreamReader(res, "UTF-8"));
-
+        try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(
+                        "LICENSE.txt"), "UTF-8"))) {
             String line;
             while ((line = reader.readLine()) != null) {
                 licenseField.append(line);
                 licenseField.append(LINE_FEED);
             }
-        } finally {
-            if (res != null) {
-                res.available();
-            }
+        }catch(IOException ex){
+            logger.log(Level.SEVERE, null, ex);
         }
+
         licenseField.setCaretPosition(0);
         licenseField.setEditable(false);
         final JScrollPane licensePane = new JScrollPane(licenseField);