source: release-kits/lirk3/resources/gs3-release-maker/apache-ant-1.6.5/src/main/org/apache/tools/ant/taskdefs/email/UUMailer.java@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 1.6 KB
Line 
1/*
2 * Copyright 2002,2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17package org.apache.tools.ant.taskdefs.email;
18
19import java.io.BufferedInputStream;
20import java.io.File;
21import java.io.FileInputStream;
22import java.io.IOException;
23import java.io.PrintStream;
24import org.apache.tools.ant.BuildException;
25import sun.misc.UUEncoder;
26
27/**
28 * An emailer that uuencodes attachments.
29 *
30 * @since Ant 1.5
31 */
32class UUMailer extends PlainMailer {
33 protected void attach(File file, PrintStream out)
34 throws IOException {
35 if (!file.exists() || !file.canRead()) {
36 throw new BuildException("File \"" + file.getName()
37 + "\" does not exist or is not "
38 + "readable.");
39 }
40
41 FileInputStream finstr = new FileInputStream(file);
42
43 try {
44 BufferedInputStream in = new BufferedInputStream(finstr);
45 UUEncoder encoder = new UUEncoder(file.getName());
46
47 encoder.encode(in, out);
48
49 } finally {
50 finstr.close();
51 }
52 }
53}
54
Note: See TracBrowser for help on using the repository browser.