You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by se...@apache.org on 2001/10/09 05:59:16 UTC
cvs commit: jakarta-james/src/java/org/apache/james/core MimeMessageInputStreamSource.java
serge 01/10/08 20:59:16
Modified: src/java/org/apache/james/core
MimeMessageInputStreamSource.java
Log:
Patch from Oki Dz. Uses Buffered streams, adds license, and adds a delete to the finalize of this object, to reduce file usage during JVM existance (rather than waiting until JVM exited)
Revision Changes Path
1.2 +35 -2 jakarta-james/src/java/org/apache/james/core/MimeMessageInputStreamSource.java
Index: MimeMessageInputStreamSource.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/core/MimeMessageInputStreamSource.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MimeMessageInputStreamSource.java 2001/08/06 03:40:07 1.1
+++ MimeMessageInputStreamSource.java 2001/10/09 03:59:16 1.2
@@ -1,11 +1,34 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE file.
+ */
package org.apache.james.core;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
+/**
+ * MimeMessageInputStreamSource.java
+ *
+ *
+ * Created:
+ *
+ * @author
+ * @version
+ *
+ * Modified by <a href="mailto:okidz@pindad.com">Oki DZ</a>
+ * Thu Oct 4 15:15:27 WIT 2001
+ *
+ */
public class MimeMessageInputStreamSource extends MimeMessageSource {
String key = null;
@@ -27,7 +50,7 @@
if (file == null) {
return in;
} else {
- return new FileInputStream(file);
+ return new BufferedInputStream(new FileInputStream(file));
}
}
@@ -38,7 +61,7 @@
if (file == null) {
//Create a temp file and channel the input stream into it
file = File.createTempFile(key, ".m64");
- FileOutputStream fout = new FileOutputStream(file);
+ OutputStream fout = new BufferedOutputStream(new FileOutputStream(file));
int b = -1;
while ((b = in.read()) != -1) {
fout.write(b);
@@ -48,5 +71,15 @@
file.deleteOnExit();
}
return file.length();
+ }
+
+ public void finalize() {
+ try {
+ if (file != null && file.exists()) {
+ file.delete();
+ }
+ } catch (Exception e) {
+ //ignore
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org