javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; boundary

JavaMail depends on some configuration files to map MIME types to Java classes (e.g., multipart/mixed to javax.mail.internet.MimeMultipart). These configuration files are loaded using the ClassLoader for the application. If the ClassLoader doesn’t function properly, these configuration files won’t be found. You can simply add below lines .. that solves the issue . MailcapCommandMap mc = … Read more

java IO Exception: Stream Closed

You’re calling writer.close(); after you’ve done writing to it. Once a stream is closed, it can not be written to again. Usually, the way I go about implementing this is by moving the close out of the write to method. public void writeToFile(){ String file_text= pedStatusText + ” ” + gatesStatus + ” ” + … Read more

Wait for file to be freed by process

A function like this will do it: public static bool IsFileReady(string filename) { // If the file can be opened for exclusive access it means that the file // is no longer locked by another process. try { using (FileStream inputStream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.None)) return inputStream.Length > 0; } catch (Exception) { return … Read more

Does close ever throw an IOException?

I have found two cases: Losing the network connection when there is still data in the buffer to be flushed. Having the file system fill up (or reaching your user limit for file size) when there is still data in the buffer to be flushed. Both of those examples depend on something happening while there … Read more