以下为java.util.List 转为 scala 中 Seq的方法:
注意需要导入包 import collection.JavaConverters._
//根据topic获取partition信息 def getPartitionInfo(consumer: KafkaConsumer[_, _], topic: String): Seq[PartitionInfo] = { import collection.JavaConverters._ val partList: Seq[PartitionInfo] = consumer.partitionsFor(topic).asScala partList }
原文地址:https://www.cnblogs.com/30go/p/8195164.html
时间: 2024-10-02 00:48:13