// for the attachment. At a minimum, the Resource contains the binary
// attachment
// data, an MD5 hash of the binary data, and the attachment MIME type.
// It can also
// include attributes such as filename and location.
Resource resource = new Resource();
resource.setData(readFileAsData(fileName));
resource.setMime(mimeType);
ResourceAttributes attributes = new ResourceAttributes();
attributes.setFileName(fileName);
resource.setAttributes(attributes);
// Now, add the new Resource to the note's list of resources
note.addToResources(resource);
// To display the Resource as part of the note's content, include an
// <en-media>
// tag in the note's ENML content. The en-media tag identifies the
// corresponding
// Resource using the MD5 hash.
String hashHex = bytesToHex(resource.getData().getBodyHash());
// The content of an Evernote note is represented using Evernote Markup
// Language
// (ENML). The full ENML specification can be found in the Evernote API
// Overview