@@ -107,9 +107,15 @@ import org.apache.tools.ant.BuildException;
* <td>Message to send inthe body of the email.</td>
* <td>Message to send inthe body of the email.</td>
* </tr>
* </tr>
* </table>
* </table>
* <tr>
* <td>includefilenames</td>
* <td>Includes filenames before file contents when set to true.</td>
* <td>No, default is <I>false</I></td>
* </tr>
* <p>
* <p>
*
*
* @author glenn_twiggs@bmc.com
* @author glenn_twiggs@bmc.com
* @author <a href="mailto:umagesh@rediffmail.com">Magesh Umasankar</a>
*/
*/
public class SendEmail extends Task {
public class SendEmail extends Task {
private String from;
private String from;
@@ -119,6 +125,7 @@ public class SendEmail extends Task {
private String toList;
private String toList;
private String subject;
private String subject;
private Vector files = new Vector();
private Vector files = new Vector();
private boolean includefilenames;
/** Creates new SendEmail */
/** Creates new SendEmail */
public SendEmail() {
public SendEmail() {
@@ -190,6 +197,15 @@ public class SendEmail extends Task {
}
}
}
}
/**
* Sets Includefilenames attribute
*
* @param includefilenames Set to true if file names are to be included.
*/
public void setIncludefilenames(boolean includefilenames) {
this.includefilenames = includefilenames;
}
/**
/**
* Executes this build task.
* Executes this build task.
*
*
@@ -230,15 +246,25 @@ public class SendEmail extends Task {
int bufsize = 1024;
int bufsize = 1024;
int length;
int length;
byte[] buf = new byte[bufsize];
byte[] buf = new byte[bufsize];
if (includefilenames) {
String filename = file.getName();
int filenamelength = filename.length();
out.println(filename);
for (int star=0; star < filenamelength; star++) {
out.print('=');
}
out.println();
}
BufferedInputStream in = null;
BufferedInputStream in = null;
try {
try {
in = new BufferedInputStream(
in = new BufferedInputStream(
new FileInputStream(file), bufsize);
new FileInputStream(file), bufsize);
while ((length = in.read(buf, 0, bufsize)) != -1) {
while ((length = in.read(buf, 0, bufsize)) != -1) {
out.write(buf, 0, length);
out.write(buf, 0, length);
}
}
if (includefilenames) {
out.println();
}
} finally {
} finally {
if (in != null) {
if (in != null) {
in.close();
in.close();