问题
I know we have an option for RDD
:
JavaRDD<String> javaRDD = coreRdd.toJavaRDD();`
is it possible to convert Dstream to JavaDStream?
回答1:
Yes, you can use the static JavaDStream<T>.fromDStream:
JavaDStream<String> javaDStream =
JavaDStream$.MODULE$.fromDStream(dStream,
scala.reflect.ClassTag$.MODULE$.apply(String.class))
Another option would be to use the class constructor, which takes an existing DStream
:
JavaDStream<String> javaDStream =
new JavaDStream<String>(dStream, scala.reflect.ClassTag$.MODULE$.apply(String.class))
来源:https://stackoverflow.com/questions/38410768/convert-a-dstream-to-javadstream