1
I am beginner in Kotlin and have the following class to read a csv file:
@Service
class ClienteImportService {
fun obtemTodosMsisdn(args: Array<File>) {
val reader = Files.newBufferedReader(Paths.get(toString()))
val csvToBean = CsvToBeanBuilder(reader)
.withType(Cliente::class)
.build()
val clientes = csvToBean.parse()
for (cliente in clientes)
System.out.println(cliente)
}
}
I’m making a mistake in the line it contains val csvToBean = Csvtobeanbuilder(Reader)
Which is the following:
Type inference failed: Not enough information to infer Parameter T in constructor Csvtobeanbuilder(Reader: Reader!) Please specify it explicitly.
What I do?
Have you tried to pass the Java class instead of Kotlin? (
withType(Cliente::class.java)
)– Anthony Accioly
Yes! But the error remains :(
– MSSantana
@Anthonyaccioly, as a thanks and respect to the help, I managed to solve as follows: val csvToBean = Csvtobeanbuilder<Client>(Reader) . withType(Client::class.java) . build()
– MSSantana
Hi @Mssantana, feel free to post your answer. It is interesting that Kotlin could not infer the generic parameters, that it is good that pass it explicitly solved :).
– Anthony Accioly