Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7589427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:09:23+00:00 2026-05-30T20:09:23+00:00

I have a application, which accepts xml files, upon uploading a invalid xml file

  • 0

I have a application, which accepts xml files, upon uploading a invalid xml file it sends a mail with brief information about the file. I also need to include the entire file content Update (attachment), what should be ideal way to do this.

This is what I tried (test code)

InputStream input = new BufferedInputStream(new FileInputStream("C:\\Simon\\csmclientbenz.xml"))
byte[] buffer = new byte[8192]

try {
    for (int length = 0; (length = input.read(buffer)) != -1;) {
        System.out.write(buffer, 0, length)
    }
} finally {
    input.close()
}

but currently it only prints part of the file. The xml file can be as large as 6MB. What is it that I am missing? Thanks

Update

Sending mail code

public void sendMail(mailProp,mailData)
{       
    logger.debug("sendMail method")

    Properties properties = System.getProperties()
    properties.setProperty("mail.smtp.host", mailProp.host)
    Session session = Session.getDefaultInstance(properties)

    try{

        MimeMessage message = new MimeMessage(session)
        message.setFrom(new InternetAddress(mailProp.from))
        message.addRecipient(Message.RecipientType.TO,new InternetAddress(mailProp.to))
        message.setSubject("Configuration failed to upload for simon@abc.com")
        message.setContent(createMessage(mailData), "text/html")
        Transport.send(message)
        System.out.println("Sent message successfully....")
    }catch (MessagingException mex) {
         mex.printStackTrace()
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:09:25+00:00Added an answer on May 30, 2026 at 8:09 pm

    As xml file can be huge upto 6 MB, sending entire file contents in message of email is not a good idea, its better to send as an email attachment. You may refer http://www.roseindia.net/javamail/SendAttachment.shtml to check how to send an attahcment while sending email.

    Even better you can compress this xml file before sending it as an attachment to reduce the attachment size using the zip uitlities of java (Ref: http://docs.oracle.com/javase/1.4.2/docs/api/java/util/zip/package-summary.html)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application which extracts data from an XML file using XPath. If
We have a Message broker application in Java which accepts messages(XML). It validates the
I have a struts2 web application which accepts both POST and GET requests in
I have a file which is an XML representation of some data that is
I have a Jersey REST service which has endpoints that can return either application/xml
I have application which needs to use a dll (also written by me) which
I have an application which really should be installed, but does work fine when
We have an application which needs to use Direct3D. Specifically, it needs at least
I have an application which behaves as a slideshow for all pictures in a
I have an application which is a portal application and I want to allow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.