code: public static String saveToFile(String baseName, String extension, byte[] content) {
          String result;
          File output = determineFilename(baseName, extension);
          FileOutputStream target = null;
          try {
              target = new FileOutputStream(output);
              target.write(content);
              result = output.getAbsolutePath();
          } catch (Exception e) {
              throw new RuntimeException(e);
          } finally {
              if (target != null) {
                  try {
                      target.close();
                  } catch (IOException ex) {
                      // what to to?
                  }
              }
          }
          return result;
      }
docs: Saves byte[] to new file.
  
  @param baseName  name for file created (without extension),
  if a file already exists with the supplied name an
  '_index' will be added.
  @param extension extension for file.
  @param content   data to store in file.
  @return absolute path of created file.