code: private void mergeFiles(@NonNull File mergedFile) throws IOException {
  
          Context context = appContextRef.get();
  
          if (context != null) {
  
              FileWriter fw;
              BufferedWriter bw;
              fw = new FileWriter(mergedFile, true);
              bw = new BufferedWriter(fw);
  
              File dir = context.getFilesDir();
              for (int i = 1; i <= maxFiles; i++) {
  
                  File file = new File(dir, name(i));
                  if (file.exists()) {
  
                      FileInputStream fis;
                      try {
  
                          fis = new FileInputStream(file);
                          BufferedReader br = new BufferedReader(new InputStreamReader(fis));
                          //noinspection TryFinallyCanBeTryWithResources
                          try {
                              String aLine;
                              while ((aLine = br.readLine()) != null) {
                                  bw.write(aLine);
                                  bw.newLine();
                              }
                          } finally {
                              br.close();
                          }
                      } catch (IOException e) {
                          e.printStackTrace();
                      }
                  }
              }
  
              bw.close();
          }
      }
docs: Merged content of internal log files.
  
  @param mergedFile Instance of a file to merge logs into.