Source:
private InputStream createInputStream() throws AudioException { try { final String filename = url.toLowerCase(); final String extension = AudioStreamUtils.getExtension(filename); switch (extension) { case M3U_EXTENSION: InputStream isM3U = new URL(url).openStream(); String urlsM3U = IOUtils.toString(isM3U); for (String line : urlsM3U.split("\n")) { if (!line.isEmpty() && !line.startsWith("#")) { url = line; break; } } break; case PLS_EXTENSION: InputStream isPLS = new URL(url).openStream(); String urlsPLS = IOUtils.toString(isPLS); for (String line : urlsPLS.split("\n")) { if (!line.isEmpty() && line.startsWith("File")) { Matcher matcher = PLS_STREAM_PATTERN.matcher(line); if (matcher.find()) { url = matcher.group(1); break; } } } break; default: break; } URL streamUrl = new URL(url); URLConnection connection = streamUrl.openConnection(); InputStream is = null; if (connection.getContentType().equals("unknown/unknown")) { int port = streamUrl.getPort() > 0 ? streamUrl.getPort() : 80; shoutCastSocket = new Socket(streamUrl.getHost(), port); OutputStream os = shoutCastSocket.getOutputStream(); String user_agent = "WinampMPEG/5.09"; String req = "GET / HTTP/1.0\r\nuser-agent: " + user_agent + "\r\nIcy-MetaData: 1\r\nConnection: keep-alive\r\n\r\n"; os.write(req.getBytes()); is = shoutCastSocket.getInputStream(); } else { is = connection.getInputStream(); } return is; } catch (MalformedURLException e) { logger.error("URL '{}' is not a valid url : '{}'", url, e.getMessage()); throw new AudioException("URL not valid"); } catch (IOException e) { logger.error("Cannot set up stream '{}': {}", url, e); throw new AudioException("IO Error"); } }

Target:
private InputStream createInputStream() throws AudioException { final String filename = url.toLowerCase(); final String extension = AudioStreamUtils.getExtension(filename); try { switch (extension) { case M3U_EXTENSION: try (final InputStream isM3U = new URL(url).openStream()) { for (final String line : IOUtils.readLines(isM3U)) { if (!line.isEmpty() && !line.startsWith("#")) { url = line; break; } } } break; case PLS_EXTENSION: try (final InputStream isPLS = new URL(url).openStream()) { for (final String line : IOUtils.readLines(isPLS)) { if (!line.isEmpty() && line.startsWith("File")) { final Matcher matcher = PLS_STREAM_PATTERN.matcher(line); if (matcher.find()) { url = matcher.group(1); break; } } } } break; default: break; } URL streamUrl = new URL(url); URLConnection connection = streamUrl.openConnection(); if (connection.getContentType().equals("unknown/unknown")) { int port = streamUrl.getPort() > 0 ? streamUrl.getPort() : 80; shoutCastSocket = new Socket(streamUrl.getHost(), port); OutputStream os = shoutCastSocket.getOutputStream(); String user_agent = "WinampMPEG/5.09"; String req = "GET / HTTP/1.0\r\nuser-agent: " + user_agent + "\r\nIcy-MetaData: 1\r\nConnection: keep-alive\r\n\r\n"; os.write(req.getBytes()); return shoutCastSocket.getInputStream(); } else { return connection.getInputStream(); } } catch (MalformedURLException e) { logger.error("URL '{}' is not a valid url: {}", url, e.getMessage(), e); throw new AudioException("URL not valid"); } catch (IOException e) { logger.error("Cannot set up stream '{}': {}", url, e.getMessage(), e); throw new AudioException("IO Error"); } }