title: How can I check if a s3path exists or not in Spark [using scala]?
body: <p>I'm looking for a cleaner way to check if a s3path is empty or not.</p>
  
  <p>My current code looks like this,</p>
  
  <pre><code> if (!s3Path.isEmpty) {
    try {
      var rdd = sc.textFile(s3Path)
      rdd.partitions.size
    } catch {
      case _: org.apache.hadoop.mapred.InvalidInputException =&gt;
        (sc.parallelize(List()))
    }
  }
  </code></pre>
  
  <p>I want to do it without creating an RDD.</p>