2016-09-28 8 views
0

Ich habe folgendes:DataSource und ByteArrayDataSource nicht kompatibel?

InputStream imageStream = classLoader.getResourceAsStream("email/logo.png"); 
DataSource fds = new ByteArrayDataSource(IOUtils.toByteArray(imageStream), "image/png"); 

Welche mir ein Fehler von Würfen:

Error:(65, 30) java: incompatible types: javax.mail.util.ByteArrayDataSource cannot be converted to org.apache.poi.poifs.nio.DataSource
Error:(66, 44) java: no suitable constructor found for DataHandler(org.apache.poi.poifs.nio.DataSource) constructor javax.activation.DataHandler.DataHandler(javax.activation.DataSource) is not applicable (argument mismatch; org.apache.poi.poifs.nio.DataSource cannot be converted to javax.activation.DataSource) constructor javax.activation.DataHandler.DataHandler(java.net.URL) is not applicable (argument mismatch; org.apache.poi.poifs.nio.DataSource cannot be converted to java.net.URL)

Was ich hier falsch mache?

+2

Wir wissen nicht, was Sie erreichen wollen, was es sehr schwer macht, Ihnen zu helfen. Möchten Sie wirklich 'org.apache.poi.poifs.nio.DataSource' verwenden? Vielleicht möchten Sie stattdessen 'javax.activation.DataSource'? –

+0

@JonSkeet, das wars! – uksz

Antwort

1

Wahrscheinlich haben Sie falsche Importe. Sie versuchen, javax.mail.util.ByteArrayDataSource zu org.apache.poi.poifs.nio.DataSource zu übertragen. Überprüfen Sie Ihre Importe.

Verwandte Themen