/**
   * Parse the text, convert and save to SRT file
   *
   * @param inputUrl Original network location
   * @param srtPath Place where SRT should be saved
   * @param languageCode The language code
   * @param inputStream InputStream of data @throws IOException
   */
  private static void parseFormatAndSave(
      String inputUrl, File srtPath, String languageCode, InputStream inputStream)
      throws IOException {
    TimedTextObject subtitleObject = null;

    String inputString = FileUtils.inputstreamToCharsetString(inputStream, languageCode);
    String[] inputText = inputString.split("\n|\r\n");

    if (inputUrl.contains(".ass") || inputUrl.contains(".ssa")) {
      FormatASS formatASS = new FormatASS();
      subtitleObject = formatASS.parseFile(inputUrl, inputText);
    } else if (inputUrl.contains(".srt")) {
      FormatSRT formatSRT = new FormatSRT();
      subtitleObject = formatSRT.parseFile(inputUrl, inputText);
    }

    if (subtitleObject != null) {
      FileUtils.saveStringFile(subtitleObject.toSRT(), srtPath);
    }
  }