how to create spark Data Frame from a string value in java can be done in few steps like below
Here are some code in java programming to create data frame with a string column, since we are not doing any operation on string column so it will go as single column only.
String input_string = "anydataflow";
List<Row> input_list=new ArrayList<Row>();
input_list.add(RowFactory.create(input_string));
List<org.apache.spark.sql.types.StructField> listOfStructField=
new ArrayList<org.apache.spark.sql.types.StructField>();
listOfStructField.add
(DataTypes.createStructField("test", DataTypes.StringType, true));
StructType structType=DataTypes.createStructType(listOfStructField);
Dataset<Row> df1 = sparkSession.createDataFrame(input_list,structType);
df1.show(false);
df1.printSchema();