title: How to minimalize multiple Audio Codes
body: <p>I am trying to minimalize my code for more than one audio. This looks just awful. How can I minimalize those many codes into one good legible code.</p>
  <pre><code>public class Sound {
      public static int playerSound (char[][] gameBoard) {
          try (AudioInputStream inStream = AudioSystem.getAudioInputStream(Sound.class.getResourceAsStream(&quot;Spieler x.wav&quot;)) ){
              Clip clip = AudioSystem.getClip();
              clip.open(inStream);
              clip.start();
          } catch (LineUnavailableException lue) {
              System.out.println(&quot;Spieler x.wav&quot; + lue.getMessage());
              lue.printStackTrace();
          } catch (UnsupportedAudioFileException uafe) {
              System.out.println(&quot;Spieler x.wav&quot; + uafe.getMessage());
              uafe.printStackTrace();
          } catch (IOException ioe) {
              System.out.println(&quot;Spieler x.wav&quot; + ioe.getMessage());
              ioe.printStackTrace();
          }
          return 0;
      }
      public static int computerSound (char[][] gameBoard) {
          try (AudioInputStream inStream = AudioSystem.getAudioInputStream(Sound.class.getResourceAsStream(&quot;Bot.wav&quot;)) ){
              Clip clip = AudioSystem.getClip();
              clip.open(inStream);
              clip.start();
          } catch (LineUnavailableException lue) {
              System.out.println(&quot;Bot.wav&quot; + lue.getMessage());
              lue.printStackTrace();
          } catch (UnsupportedAudioFileException uafe) {
              System.out.println(&quot;Bot.wav&quot; + uafe.getMessage());
              uafe.printStackTrace();
          } catch (IOException ioe) {
              System.out.println(&quot;Bot.wav&quot; + ioe.getMessage());
              ioe.printStackTrace();
          }
          return 0;
      } 
  </code></pre>