I've been beating my head against the desk for about an hour now just trying to find some way of getting say... an array of bytes off the clipboard. Instead, all I can seem to find is information on how to get plain text from the clipboard... that's not helpful at all.
I've tried following this: Java getting bytes of clipboard
I've also tried following this: http://mrbool.com/manipulating-clipboard-content-with-java/24758
Every time I run into the silly DataFlavor being "unsupported". Surely there's just something simple that I'm missing here... I mean... how can it support plain text, images, and java objects, but NOT have the basic functionality that just has to be under the hood of all this?
Sorry if I sound sarcastic and pissed off here... Java seems to have that effect on me. :(
Awt Clipboard and MIME types
InsideClipboard shows that the content's MIME type is
application/spark editor
You should be able to create a MIME type DataFlavor by using the constructor
DataFlavor(String mimeType, String humanReadableFormat)
in which case the class representation will be anInputStream
from which you can extract bytes in a classic manner...However, this clipboard implementation is very strict on the mime type definition and you cannot use spaces in the format id, which is too bad because your editor seems to put a space there :(
Possible solution, if you have access to JavaFX
JavaFX's clipboard management is more lenient and tolerates various "Format Names" (as InsideClipboard calls them) in the clipboard, not just no-space
type/subtype
mime formats like in awt.For example, using LibreOffice Draw 4.2 and copying a Rectangle shape, awt only sees a
application/x-java-rawimage
format whereas JavaFX sees all the same formats as InsideClipboard :You can then get the raw data from the JavaFX clipboard in a
java.nio.ByteBuffer