I have some code
String url = http://site/some-file.pdf
HttpURLConnection fileRequest = (HttpURLConnection) new URL(fileUrl).openConnection();
Path file = Files.createFile(Paths.get("mydirectory" + "filename" +".pdf"));
Files.write(file, IOUtils.toByteArray(fileRequest.getInputStream()));
This code writes gets file from url and write it to my local home(disk D, for instance)
How to make it attached to mail sender without saving locally? Is it possible?