title: Spark Reading .7z files
body: <p>I am trying to read the spark .7z files using scala or java. I dont find any appropriate methods or functionality.</p>
  <p>For the zip file, i am able to read as the ZipInputStream class takes a Input stream, but for the 7Z files the class SevenZFile doesnt take any input stream.
  <a href="https://commons.apache.org/proper/commons-compress/javadocs/api-1.16/org/apache/commons/compress/archivers/sevenz/SevenZFile.html" rel="nofollow noreferrer">https://commons.apache.org/proper/commons-compress/javadocs/api-1.16/org/apache/commons/compress/archivers/sevenz/SevenZFile.html</a></p>
  <p>Zip file code</p>
  <pre><code>spark.sparkContext.binaryFiles(&quot;fileName&quot;).flatMap{case (name: String, content: PortableDataStream) =&gt;
          val zis = new ZipInputStream(content.open)
          Stream.continually(zis.getNextEntry)
                .takeWhile(_ != null)
                .flatMap { _ =&gt;
                    val br = new BufferedReader(new InputStreamReader(zis))
                    Stream.continually(br.readLine()).takeWhile(_ != null)
                }}
  </code></pre>
  <p>I am trying similar code for the 7z files something like</p>
  <pre><code>spark.sparkContext.binaryFiles(&quot;&quot;filename&quot;&quot;).flatMap{case (name: String, content: PortableDataStream) =&gt;
          val zis = new SevenZFile(content.open)
          Stream.continually(zis.getNextEntry)
                .takeWhile(_ != null)
                .flatMap { _ =&gt;
                    val br = new BufferedReader(new InputStreamReader(zis))
                    Stream.continually(br.readLine()).takeWhile(_ != null)
                }}
  </code></pre>
  <p>But SevenZFile doesnt accept these formats.Looking for ideas.</p>
  <p>If the file is in local filessytem following solution works, but my file is in hdfs</p>
  <p>Local fileSystem Code</p>
  <pre><code> public static void decompress(String in, File destination) throws IOException {
          SevenZFile sevenZFile = new SevenZFile(new File(in));
          SevenZArchiveEntry entry;
          while ((entry = sevenZFile.getNextEntry()) != null){
              if (entry.isDirectory()){
                  continue;
              }
              File curfile = new File(destination, entry.getName());
              File parent = curfile.getParentFile();
              if (!parent.exists()) {
                  parent.mkdirs();
              }
              FileOutputStream out = new FileOutputStream(curfile);
              byte[] content = new byte[(int) entry.getSize()];
              sevenZFile.read(content, 0, content.length);
              out.write(content);
              out.close();
          }
      }
  </code></pre>
  <p>After all these years of spark evolution there should be easy way to do it.</p>