code: private FileOutputStream createFileOutputStream(String newFileName, boolean append)
              throws FileNotFoundException {
          try {
              //
              //   attempt to create file
              //
              return new FileOutputStream(newFileName, append);
          } catch (FileNotFoundException ex) {
              //
              //   if parent directory does not exist then
              //      attempt to create it and try to create file
              //      see bug 9150
              //
              String parentName = new File(newFileName).getParent();
              if (parentName != null) {
                  File parentDir = new File(parentName);
                  if (!parentDir.exists() && parentDir.mkdirs()) {
                      return new FileOutputStream(newFileName, append);
                  } else {
                      throw ex;
                  }
              } else {
                  throw ex;
              }
          }
      }
docs: Creates a new FileOutputStream of a new log file, possibly creating first all the needed parent directories
  
  @param newFileName Filename of new log file to be created
  @param append      If file should be appended
  @return newly created FileOutputStream
  @throws FileNotFoundException if creating log file or parent directories was unsuccessful