Im having a different problem ... I was a bit googled looking, but havent found anything about my problem, so I ask here ... I have a JasperPrint object where I create a document ... The problem is that I need to create java.io.File from this JasperPrint without saving the file to the computer.
What I need to do: send the file by email. And this file should be generated by jasperreport. I cannot save the stream on the machine to delete it later ... so I need to take a file in memory or something similar at runtime ...
So ... I have my jasperprint object and you need to get java.io.File from this ... Does anyone know what I can do?
Andrew ... could not reply to the comment, so I wrote it here ... In javax.mail I did like this:
File fileAttachment = myfile;
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(fileAttachment);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(fileAttachment.getName());
multipart.addBodyPart(messageBodyPart);
and its work when I transfer the file to it from my machine ... So I think it will work when I use java.io.File, even if it is only in memory ...
source
share