Hi @Jitender Yadav,
You may read the data as byte stream to read and write the data files if you want to deal with binary files.
import org.apache.hadoop.fs.{FileSystem, Path}
val hadoopfs : FileSystem = FileSystem.get(sc.hadoopConfiguration)
//read the file as Input byte stream
val hadoopfsStreem = hadoopfs.open(new Path("<hdfs file Path>"))
// to create the directory
if (!hadoopfs.exists(path)) {
hadoopfs.mkdirs(path)
}
// to write the data
hadoopfs.create("<>",<options>)
the Java API docs can be found here
please not that, this operation will not run in parallel, instead it runs of the driver so for dealing with larger volumes of data you definitely need to use the conventional spark Api's to read and write the data using RDD's/DataSets for better performance.
Hope this helps !!