- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
<分区>
我正在创建一个应用程序来发送带附件的邮件。当我附加一个小的 zip 文件时它工作正常但是当我附加一个更大的 (> 1mb) zip 文件时它返回错误“java.net.SocketException:软件导致连接中止:套接字写入错误”并且我的应用程序挂起。
我附加文件的代码是:
protected void addAtachments(String[] attachments, Multipart multipart)
throws MessagingException, AddressException {
System.out.println("attaching");
for (int i = 0; i <= attachments.length - 1; i++) {
String filename = attachments[i];
MimeBodyPart attachmentBodyPart = new MimeBodyPart();
//use a JAF FileDataSource as it does MIME type detection
DataSource source = new FileDataSource(filename);
attachmentBodyPart.setDataHandler(new DataHandler(source));
attachmentBodyPart.setFileName(filename);
//add the attachment
multipart.addBodyPart(attachmentBodyPart);
System.out.println("attachment added: " +attachments[i]);
}
还有,有什么方法可以使用 javamail 更快地附加文件吗?发送附加消息花费了太多时间。
堆栈跟踪:
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 25, isSSL false
220 mx.google.com ESMTP g16sm81301847ibs.8
DEBUG SMTP: connected to host "smtp.gmail.com", port: 25
EHLO vishal
250-mx.google.com at your service, [122.178.231.153]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250 ENHANCEDSTATUSCODES
DEBUG SMTP: Found extension "SIZE", arg "35882577"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
STARTTLS
220 2.0.0 Ready to start TLS
EHLO vishal
250-mx.google.com at your service, [122.178.231.153]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH
250 ENHANCEDSTATUSCODES
DEBUG SMTP: Found extension "SIZE", arg "35882577"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XOAUTH"
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Attempt to authenticate
AUTH LOGIN
334 VXNlcm5hbWU6
dmlzaGFscmsuMDU1QGdtYWlsLmNvbQ==
334 UGFzc3dvcmQ6
dmlzaGFsQG9yYWNsZQ==
235 2.7.0 Accepted
DEBUG SMTP: use8bit false
MAIL FROM:<xyz@gmail.com>
250 2.1.0 OK g16sm81301847ibs.8
RCPT TO:<xyz@yahoo.co.in>
250 2.1.5 OK g16sm81301847ibs.8
DEBUG SMTP: Verified Addresses
DEBUG SMTP: xyz@yahoo.co.in
DATA
------=_Part_1_25068634.1322105586140
Content-Type: application/octet-stream;
name="C:\\Documents and Settings\\Vishal Kulkarni\\MyDocuments\\akon.zip"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="C:\\Documents and Settings\\Vishal Kulkarni\\My Documents\\akon.zip"
UEsDBBQACAAIAGJMcj8AAAAAAAAAAAAAAAAkAAAARW1pbmVtLSAwMSAtIFB1YmxpYyBBbm5vdW5j
ZW1lbnQubXAz1LtlVBxB1y46DK7BneDu7u7uHmRw9+AwgxNcg7tb8BAgBCe4S7AQCBIkuATtm7zf
e++Pc3/cX3etc2qtvaa6q2s/PU937X6qa7eyHC886G+B95XVVFf/WyH5a7Zu9iAHHx8PEU5OVw9e
DnsviKtrAIfXWz1lPZ6/zfh/TeutlYujNZW0m5v7WzdrW1dbNx89HVnVvy3gv8atZyyv8/cX8V9d
WFhYT1ZT47+bTNyCzHrSajJ/q1h/TdfF0ZVK1wFiE0ClpqWlo2zwdx8jCGSozqlua+MIkXWBeHtr
eTm6QrwClOVAn0Ms52h/7qhGlyiVszDJvf5vB+b/pYOurbW7m83/dPlfy3+7/MXWsoU4G0Bc3tqC
XqD/z34cEEja19YLYm+rZutr6wJSwwSB9LTkuf82If81eVdHN1vX/5fT/3ML8JiC8P91jJHj3/sB
输出在 15 或 20 分钟后继续打印此加密数据,但出现错误
java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at com.sun.net.ssl.internal.ssl.OutputRecord.writeBuffer(OutputRecord.java:283)
at com.sun.net.ssl.internal.ssl.OutputRecord.write(OutputRecord.java:272)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:665)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
at com.sun.mail.util.TraceOutputStream.write(TraceOutputStream.java:101)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:109)
at com.sun.mail.util.CRLFOutputStream.write(CRLFOutputStream.java:87)
at com.sun.mail.smtp.SMTPOutputStream.write(SMTPOutputStream.java:74)
at com.sun.mail.util.CRLFOutputStream.write(CRLFOutputStream.java:65)
at com.sun.mail.util.BASE64EncoderStream.encode(BASE64EncoderStream.java:182)
at com.sun.mail.util.BASE64EncoderStream.write(BASE64EncoderStream.java:135)
at com.sun.mail.util.BASE64EncoderStream.write(BASE64EncoderStream.java:96)
at javax.activation.DataHandler.writeTo(DataHandler.java:293)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1350)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:845)
at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:361)
at com.sun.mail.handlers.multipart_mixed.writeTo(multipart_mixed.java:85)
at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:868)
at javax.activation.DataHandler.writeTo(DataHandler.java:301)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1350)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1683)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:585)
at escape.SendMailUsingAuthentication.postMail(SendMailUsingAuthentication.java:131)
at escape.SendMailFrame.sendButtonActionPerformed(SendMailFrame.java:427)
at escape.SendMailFrame.access$300(SendMailFrame.java:29)
at escape.SendMailFrame$4.actionPerformed(SendMailFrame.java:135)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6038)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
javax.mail.MessagingException: IOException while sending message;
nested exception is:
at java.awt.Window.dispatchEventImpl(Window.java:2429)
at java.awt.Component.dispatchEvent(Component.java:4240)
java.net.SocketException: Software caused connection abort: socket write error
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:625)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at escape.SendMailUsingAuthentication.postMail(SendMailUsingAuthentication.java:131)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at escape.SendMailFrame.sendButtonActionPerformed(SendMailFrame.java:427)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at escape.SendMailFrame.access$300(SendMailFrame.java:29)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at escape.SendMailFrame$4.actionPerformed(SendMailFrame.java:135)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6038)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2429)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at com.sun.net.ssl.internal.ssl.OutputRecord.writeBuffer(OutputRecord.java:283)
at com.sun.net.ssl.internal.ssl.OutputRecord.write(OutputRecord.java:272)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:665)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
at com.sun.mail.util.TraceOutputStream.write(TraceOutputStream.java:101)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:109)
at com.sun.mail.util.CRLFOutputStream.write(CRLFOutputStream.java:87)
at com.sun.mail.smtp.SMTPOutputStream.write(SMTPOutputStream.java:74)
at com.sun.mail.util.CRLFOutputStream.write(CRLFOutputStream.java:65)
at com.sun.mail.util.BASE64EncoderStream.encode(BASE64EncoderStream.java:182)
at com.sun.mail.util.BASE64EncoderStream.write(BASE64EncoderStream.java:135)
at com.sun.mail.util.BASE64EncoderStream.write(BASE64EncoderStream.java:96)
at javax.activation.DataHandler.writeTo(DataHandler.java:293)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1350)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:845)
IOException while sending message
at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:361)
at com.sun.mail.handlers.multipart_mixed.writeTo(multipart_mixed.java:85)
at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:868)
at javax.activation.DataHandler.writeTo(DataHandler.java:301)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1350)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1683)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:585)
... 29 more
如果附件很小,它可以正常工作,但需要 10 到 11 分钟才能发送邮件
我正在使用 Jfilechooser 来选择要附加的文件
我正在尝试使用一个使用 JNI 的库。 我已经尝试了开发人员提供的示例应用程序,它可以工作。所以我知道这不是库中的错误。 我认为我在导入库的过程中做错了什么: 将 .so 文件复制到我的 libs 文
使用Websphere 应用程序服务器 + Wicket 1.6我的挂载 URL 遇到一些问题。 当我调用类似于以下内容的网址时:localhost:9080/danesCooking/pies/me
我有一个应用程序在 Win2k3 VM 上的 Apache Tomcat 5.5 上运行。该应用程序提供 XML,供某些电话设备使用,作为我们 IVR 基础设施的一部分。反过来,应用程序从一些 SOA
升级到雅加达给我带来了一些问题。。我正在使用以下maven插件:。并且我使用episodal编译(有库)。突然间,我面临着以下问题:。更仔细的检查发现,XJC突然生成了以下字段:。这是它以前没有产生的
Jenkins 有一个可用于自由式构建作业的 $CAUSE 变量。 如何在工作流程中访问此内容或类似内容? 我的团队在现有临时构建的电子邮件输出中使用它。我们希望在新的基于工作流的工作中继续这样做。
错误:无法完成 Gradle 执行。 原因: Could not create parent directory for lock file C:\Program Files\Android\Andr
如何确定多个浏览器 UI 事件是否由相同的基本 UI 交互引起? 例如,用户单击和事件监听器会触发“blur”和“mousedown”事件。有没有办法确定这两个事件都是由一次用户点击引起的? 最佳答案
它可以编译,但不会从 .o 文件链接到可执行文件。我已经删除了从现在到运行良好时所做的所有更改(基本上,str_to_int 中的所有内容)。 我的代码: #include #include in
关于 Java 的 InterruptedException 有一些有趣的问题和答案。 ,例如 The Cause of InterruptedException和 Handling Interrup
我使用 android 工具 “内存监视器” 来修复内存泄漏。这很有帮助。 但是,我需要澄清一下。 有时在运行该应用程序后,分配的内存为“47MB”。当与应用交互时,它会上下移动。 然后当我点击“ca
我正在调查由于堆损坏而导致的崩溃。由于这个问题很重要并且涉及分析堆栈和转储结果,因此我决定对与崩溃相关的文件进行代码审查。 坦率地说,我对堆何时可能损坏没有深入的了解。 如果您能提出可能导致堆损坏的方
假设我们有一个名为 feature-branch 的功能分支。该分支的开发人员分支获取他们的票,然后打开一个 PR 到 feature-brach。 如果发生以下情况: 开发人员A从feature-b
两个线程同时访问fileName。 Set If 0 使死锁。但如果 1 一切顺利。 那么是什么导致了这种情况? 最佳答案 确保您没有在主线程上同步调用 +[PHAssetResource asset
不幸的是,我还不是正则表达式专家,因此遇到了以下问题:假设我有一个包含多个链式异常的 Java 堆栈跟踪,我想要达到的是提取以“Caused by”开头的最后一行。 javax.servlet.Ser
我确信这是我所缺少的非常简单的东西。我使用 makeKeyAndOrderFront: 打开一个窗口,它第一次工作。当我关闭窗口并尝试再次打开它时,它退出并给出错误EXC_BAD_ACCESS。我的代
我刚刚探索了 Rank2Types 和 RankNTypes,试图熟悉它们。但我不明白为什么以下不起作用。 g :: (forall a. forall b. a -> b) -> x -> y ->
我想验证输入是否严格是由 10-16 个字符长组成的数字。根据用户输入值,我将在输入字段下方显示一条消息。问题是,当我去使用时为了帮助完成此任务,它会导致应用程序抛出异常。 我是 JSF 新手,我很难
许多内置的 Java 异常无法接受“原因”。有什么方法可以为这些异常指定原因吗? 我希望能够链接异常,就像这个 InterruptedException 示例一样: try{ //thread
我创建了一个 JSP Mysql 和 Bootstrap Crud 应用程序。当我单击“更新”按钮时,将调用函数 validation() 来更新所有字段,在成功更新后,它将重定向到另一个 JSP 页
我看到了奇怪的情况:在我的 Android 应用程序代码中使用类似这样的东西时我没有收到任何错误: @Override public void onBackPressed() { if
我是一名优秀的程序员,十分优秀!