以下为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 }