question: public static void writeStringToFile ( String path , String toWrite , SparkContext sc ) throws IOException { FileSystem fileSystem = FileSystem . get ( sc . hadoopConfiguration ( ) ) ; try ( BufferedOutputStream bos = new BufferedOutputStream ( fileSystem . create ( new Path ( path ) ) ) ) { bos . write ( toWrite . getBytes ( "UTF-8" ) ) ; } }
target:  Write a String to a file (on HDFS or local) in UTF-8 format