I am reposting this message because I feel like I did not ask the right questions in the previous post.
I am trying to email a file attachment in
Java from Unix and am unsuccessful at many tries. Below is my code. I do get the email but without the file attachment.
In the email command I am redirecting the file in as an attachment. I feel that the problem is with
"<" .
I get the email message when I execute the java program, however, I do not get the attachment in the email.
Does anyone know if there is any way to attach a file from mailx or uuencode? Is it possible to use java mail api in a java application program? Would PipedOutputStream be useful in this? The mail command that mails the file is in BOLD( mailCmd = "mailx -s here
arpita.patel@prudential.com < ap1"

Please help.
import java.io.*;
import java.util.*;
public class UnixCmd {
public static void main (
String args[])
{
String line = null;
try
{
System.out.println("This application will mail a file using uuencode");
String strCmd = "uuencode ap ap1";
System.out.println("command: " + strCmd);
Process p = Runtime.getRuntime().exec(strCmd);
File inFile = new File("ap");
FileInputStream f = new FileInputStream(inFile);
InputStream is = p.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(is));
File outfile = new File("ap1");
BufferedWriter out = new BufferedWriter(new FileWriter(outfile));
String strLine;
while ((strLine = in.readLine()) != null)
{
System.out.println(strLine);
out.write(strLine + "\n");
out.flush();
}
in.close();
out.close();
String mailCmd;
mailCmd = "mailx -s here
arpita.patel@prudential.com < ap1";
System.out.println("mailCmd: " + mailCmd);
Process m = Runtime.getRuntime().exec(mailCmd);
}
catch (IOException e)
{
System.out.println("ERROR: " + e);
}
}
}
Thanks,
Arpita.