code: public static String readStringFromFile(String path, SparkContext sc) throws IOException {
          FileSystem fileSystem = FileSystem.get(sc.hadoopConfiguration());
          try (BufferedInputStream bis = new BufferedInputStream(fileSystem.open(new Path(path)))) {
              byte[] asBytes = IOUtils.toByteArray(bis);
              return new String(asBytes, "UTF-8");
          }
      }
docs: Read a UTF-8 format String from HDFS (or local)
  
  @param path Path to write the string
  @param sc   Spark context