Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to download .exe file from a POP3 server using JavaMail

843830Nov 17 2005
Hi to all,
Iam unable to download the .exe file from a mailserver,it is giving exception like FileNotFound.iam successful to download all kind of files except .exe(installation file or i can say a software exe file).
what is the problem?

and this is my code
*********************

Message[] m=folder.getMessges();
dumpPart(m);
}
public static void dumpPart(Part p) throws Exception {
// if (p instanceof Message) dumpEnvelope((Message)p);
System.out.println("CONTENT-TYPE: " + p.getContentType());

Object o = p.getContent();
if (o instanceof String) {
System.out.println("This is a String");
System.out.println((String)o);
} else if (o instanceof Multipart) {
System.out.println("This is a Multipart");
Multipart mp = (Multipart)o;
int count = mp.getCount();
System.out.println("****************************************");
System.out.println("count" + count);
System.out.println("****************************************");
for (int i = 0; i < count; i++){
System.out.println("CONTENT-TYPE: " + p.getContentType());
dumpPart(mp.getBodyPart(i));
}
} else if (o instanceof InputStream) {
System.out.println("This is just an input stream");
InputStream is = (InputStream)o;

String filename=System.currentTimeMillis()+".exe ";

FileOutputStream fos=new FileOutputStream(filename);
int c;
while ((c = is.read()) != -1)
//System.out.write(c);
fos.write((char)c);
}

}//dumpPart


that is my code snipnet,
do i have to make any chages to my code?


by
Nagaraju G
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 15 2005
Added on Nov 17 2005
0 comments
99 views