Java获取剪贴板的字节数 [英] Java getting bytes of clipboard

查看:177
本文介绍了Java获取剪贴板的字节数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想获取用户剪贴板的实际字节。我找不到这样做的方法,我所能找到的就是如何将剪贴板作为字符串获取。

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);

我们将不胜感激。

推荐答案

一旦有了剪贴板的String表示形式,就可以通过 String#getBytes()

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

byte[] clipboardBytes = clipboardString.getBytes();

这篇关于Java获取剪贴板的字节数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆