title: Save Bitmap in Android as JPEG in External Storage in a folder
body: <p>I am using this code to save Bitmap in External Storage but it does not create the folder if it not exists:</p>
  
  <pre><code>String path = Environment.getExternalStorageDirectory().toString();
          OutputStream fOutputStream = null;
          File file = new File(path + "/Captures/", "screen.jpg");
          try {
              fOutputStream = new FileOutputStream(file);
  
              capturedBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOutputStream);
  
              fOutputStream.flush();
              fOutputStream.close();
  
              MediaStore.Images.Media.insertImage(getContentResolver(), file.getAbsolutePath(), file.getName(), file.getName());
          } catch (FileNotFoundException e) {
              e.printStackTrace();
              Toast.makeText(this, "Save Failed", Toast.LENGTH_SHORT).show();
              return;
          } catch (IOException e) {
              e.printStackTrace();
              Toast.makeText(this, "Save Failed", Toast.LENGTH_SHORT).show();
              return;
          }
  </code></pre>
  
  <p>How can I save the image in the new directory if not exists and save default if the folder is there in the device?</p>