Java getting bytes of clipboard

怎甘沉沦 提交于 2019-12-24 14:00:04

问题


So I want to get the actual bytes of the user's clipboard. I can't find a way of doing this, all I find is how to get the clipboard as a String.

To get the clipboard as a String, I'd have to do something like this:

String data = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);

Help will be appreciated.


回答1:


Once you have the String representation of the clipboard, you can get the bytes via String#getBytes().

byte[] clipboardBytes = clipboardString.getBytes();


来源:https://stackoverflow.com/questions/13094723/java-getting-bytes-of-clipboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!