我通过使用javabase64-1.3.1.jar库解决了我的问题。
OutputStream fos2 = FileUtil.getOutputStream(base64FileName, FileUtil.HDD);InputStream in2 = FileUtil.getInputStream(fileName, FileUtil.HDD);base64.enpre(in2, fos2);in2.close();fos2.close();
我首先将base64字符串存储到文本文件中。
public void createbase64String(InputStream in) throws IOException { baos = new ByteArrayOutputStream(); byte[] buf = new byte[BUFFER_SIZE]; int readNum = 0; smtp.addbase64("tt"); try { while ((readNum = in.read(buf)) >= 0) { baos.write(buf, 0, readNum); smtp.addbase64(baos.toString()); baos.reset(); } } catch (IOException ex) { LogUtil.error("Sending of base64 String to SMTP: IOException: " + ex); } finally { if (in != null) { in.close(); baos.close(); } } baos = null; buf = null;}然后将每行发送到smtp的套接字输出流。



